October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

Linux Port Checks: 5 Ways to Test TCP and UDP Reachability

Five practical Linux port checks with ss, nc, nmap, and Bash—and what their results can and cannot prove.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To check whether a Linux port is reachable from another machine, run a connection test such as nc or nmap on that remote machine—or at least from the network position you need to verify. To see whether a service has a local listening socket, use ss. These answer different questions: a local listener does not prove outside clients can reach it, and a successful TCP connection does not prove the application protocol works.

Choose the check that matches your question

Method What it checks Best suited to
ss Local sockets and, with privileges, owning processes Confirming that a service has a local socket and checking its bind address
nc TCP Whether a TCP connection attempt succeeds A quick check of one port or a supported range
nc UDP A preliminary UDP probe A basic probe, with no definitive result when the service does not respond
nmap Scanner-observed TCP or UDP port states Scanning one port, a range, or identifying service versions when appropriate
Bash /dev/tcp Whether Bash can open a TCP connection A small, bounded TCP readiness check in a script

For a remote-reachability question, test from the client or network whose access matters. A scan from the server itself may take a different route and cannot establish that an external client can connect.

As an Amazon Associate I earn from qualifying purchases.

1. Inspect local listening sockets with ss

On the Linux machine running the service, use:

sudo ss -tunlp

The options request TCP sockets (-t), UDP sockets (-u), numeric addresses and ports (-n), listening sockets (-l) and process details (-p). Process information for sockets owned by other users may require root privileges.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To inspect a particular TCP port, such as port 22, run:

#1 Best Overall
Sale
TP-Link USB to Ethernet Adapter,Support Nintendo Switch,1Gbps,Plug and Play | Gigabit RJ45 to USB A 3.0 Network Adapter, Foldable & Portable Design, Compatible w/ Windows, macOS, & Linux(UE306)
  • 𝐇𝐢𝐠𝐡-𝐒𝐩𝐞𝐞𝐝 𝐔𝐒𝐁 𝐄𝐭𝐡𝐞𝐫𝐧𝐞𝐭 𝐀𝐝𝐚𝐩𝐭𝐞𝐫 - UE306 is a USB 3.0 Type-A to RJ45 Ethernet adapter that adds a reliable wired network port to your laptop, tablet, or Ultrabook. It delivers fast and stable 10/100/1000 Mbps wired connections to your computer or tablet via a router or network switch, making it ideal for file transfers, HD video streaming, online gaming, and video conferencing.
  • 𝐔𝐒𝐁 𝟑.𝟎 𝐟𝐨𝐫 𝐅𝐚𝐬𝐭𝐞𝐫, 𝐌𝐨𝐫𝐞 𝐒𝐭𝐚𝐛𝐥𝐞 𝐃𝐚𝐭𝐚 𝐓𝐫𝐚𝐧𝐬𝐟𝐞𝐫𝐬- Powered via USB 3.0, this adapter provides high-speed Gigabit Ethernet without the need for external power(10/100/1000Mbps). Backward compatible with USB 2.0/1.1, it ensures reliable performance across a wide range of devices.
  • 𝐒𝐮𝐩𝐩𝐨𝐫𝐭𝐬 𝐍𝐢𝐧𝐭𝐞𝐧𝐝𝐨 𝐒𝐰𝐢𝐭𝐜𝐡- Easily connect your Nintendo Switch to a wired network for faster downloads and a more stable online gaming experience compared to Wi-Fi.
  • 𝐏𝐥𝐮𝐠 𝐚𝐧𝐝 𝐏𝐥𝐚𝐲- No driver required for Nintendo Switch, Windows 11/10/8.1/8, and Linux. Simply connect and enjoy instant wired internet access without complicated setup.
  • 𝐁𝐫𝐨𝐚𝐝 𝐃𝐞𝐯𝐢𝐜𝐞 𝐂𝐨𝐦𝐩𝐚𝐭𝐢𝐛𝐢𝐥𝐢𝐭𝐲- Supports Nintendo Switch, PCs, laptops, Ultrabooks, tablets, and other USB-powered web devices; works with network equipment including modems, routers, and switches.
sudo ss -tlnp sport = :22

Replace 22 with the port you want to inspect. TCP listeners appear with the state LISTEN. UDP is connectionless, so its sockets commonly appear as UNCONN; filtering output only for LISTEN can hide UDP sockets. The bind address is important: 127.0.0.1 is loopback and accepts local connections only, while 0.0.0.0 represents all IPv4 interfaces. An address bound to a particular interface is limited to that interface.

ss reports local socket state. It does not test routing, external firewall rules, or whether a client elsewhere can reach the port. For that, use a remote connection test below.

2. Test a TCP connection with nc

A common OpenBSD netcat form for checking one TCP port is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Amazon Basics USB 3.0 to 10/100/1000 Gigabit Ethernet Internet Adapter, Compatible with Windows and macOS, Black
  • Connects a USB 3.0 device (computer/laptop) to a router, modem, or network switch to deliver Gigabit Ethernet to your network connection. Does not support Smart TV or gaming consoles (e.g.Nintendo Switch).
  • Supported features include Wake-on-LAN function, Green Ethernet & IEEE 802.3az-2010 (Energy Efficient Ethernet)
  • Supports IPv4/IPv6 pack Checksum Offload Engine (COE) to reduce Cental Processing Unit (CPU) loading
  • Compatible with Windows 8.1 or higher, Mac OS
nc -z -v -w 3 HOST PORT

Replace HOST with the target hostname or IP address and PORT with the port number. The -z option checks without sending application data, -v requests a result message, and -w 3 bounds the attempt with a timeout. A form such as nc -z -v HOST 20-80 can check a range when supported by the installed version.

Netcat implementations do not all accept the same options. Check nc -h or the local manual with man nc before relying on flags, especially on systems that provide traditional netcat or Ncat rather than OpenBSD netcat. The Ubuntu Noble manual documents netcat-openbsd 1.226-1ubuntu2: nc manual page.

A successful result means the TCP connection attempt succeeded; it does not confirm that the application is usable. The service may require TLS, authentication, or a particular application request. Use a protocol-appropriate client to test those layers.

Rank #3
USB A/C to Ethernet Adapter, 3xUSB3.0 and 1000M RJ45 Network hub for Laptop
  • [Expansion Ports] The USB C to Ethernet Adapter expands the device to three USB 3.0 ports and one Gigabit Ethernet port. Provides you more peripheral ports while maintaining a stable network connection, plug and play, no driver required.
  • [Gigabit Network Port] ALL-LUCKY USB Ethernet Adapter transmission rate up to 1000Mbps, also compatible with 10/100Mbps bandwidth. It allows you to enjoy a smooth and stable network connection and avoid too much lag. (Note: To reach 1Gbps, please use CAT6 or above Ethernet cable connection)
  • [Convertible Connector]This usb hub with ethernet not only has USB-A connector, but also can be converted to USB-C connector, so that you can easily convert the connector according to the device port, improve the convenience of use.
  • [High-Speed Data Transfer] The usb to ethernet adapter adopts USB 3.0 transmission technology, supports up to 5Gbps transmission rate, and is compatible with USB 2.0(480Gbps),USB 1.0(12Mbps), easily transfer video, files and other data for you in seconds. (Note: Maximum output current is 900mA, does not support charging devices.)
  • [Widely Compatible]The usb c ethernet adapter for iMac, MacBook Pro, iPad Pro, XPS and many other devices. Compatible with Windows 11/10/8.1/8, Mac OS, iPad OS, Chrome OS.(Note: Driver is required on Win 7) It can be used in office, school, library and other occasions, compact and portable, easy to carry around.

3. Probe a UDP port with nc

To select UDP, add -u:

nc -z -v -u HOST PORT

Treat this as a preliminary probe, not a definitive open-or-closed test. UDP has no TCP-style connection handshake, and a silent service may not reply to an arbitrary probe. No error or response therefore does not establish that an application is listening. Where possible, send a valid request for the service’s protocol and check for its expected response. For broader UDP scanning, Nmap can report the uncertainty explicitly.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

4. Scan and interpret ports with nmap

For one TCP port, run:

nmap -p PORT HOST

Replace PORT and HOST with the values to test. By default, Nmap ordinarily checks the 1,000 most common TCP ports; to request a full TCP port range, use:

nmap -sT -p- HOST

Here -sT selects a TCP connect scan and -p- selects ports 1 through 65,535. For one UDP port, use:

Rank #4
Sale
Anker USB C to Ethernet Adapter, Portable 1 Gbps Network Hub | Aluminum, Compact, 10/100/1000Mbps, for MacBook Pro, iPad Pro, ChromeBook, XPS, Galaxy and More
  • The Anker Advantage: Join the 65 million+ powered by our leading technology.
  • Instant Internet: Connect to the internet instantly from virtually any USB-C 3.0 device, and enjoy stable connection speeds of up to 1 Gbps.
  • Lightweight and Compact: The space-saving and portable design measures just over half an inch thick and weighs about the same as a AA battery.
  • Premium Build: Features a sleek aluminum exterior and braided-nylon cable to complement the design of high-end devices.
  • What You Get: PowerExpand USB-C to Gigabit Ethernet Adapter, welcome guide, 18-month worry-free warranty, and friendly customer service.
sudo nmap -sU -p PORT HOST

Nmap labels a port according to what its probes observe, not simply according to whether a local socket exists:

  • open: The target is accepting packets on the port.
  • closed: The target responded that no application is listening there.
  • filtered: Filtering or another obstacle prevents Nmap from determining whether the port is open. The label does not identify a particular firewall or device.
  • open|filtered: Nmap received no response to a UDP probe, so it cannot distinguish an open port that stayed silent from a filtered probe.

UDP scans can take longer because open or filtered ports often do not respond, and ICMP errors from closed ports may be rate-limited. If the question is which service is answering rather than just what state a port appears to have, consider version detection with -sV where appropriate. Nmap’s reference guide documents scan options and state meanings: Nmap reference guide.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Scan only systems you own or are authorized to assess. Nmap’s basic usage guide also covers choosing scan targets and options: Linuxize: Check Open Ports in Linux.

Best Value
BENFEI USB 3.0 to Ethernet Adapter, USB C to RJ45 Gigabit LAN (1000Mbps) Network Adapter, Compatible with MacBook/Pro/Air, Surface Pro, Windows 11/10/8/7, Mac OS [Aluminium Shell&Nylon Cable]
  • COMPACT DESIGN - The compact-designed portable BENFEI USB A/C to Ethernet adapter connects your computer or tablet to a router,modem or network switch for network connection. It adds a standard RJ45 port to your Ultrabook, notebook or Macbook Air for file transferring, video conferencing, gaming, and HD video streaming.
  • SUPERIOR STABILITY - Built-in advanced IC chip works as the bridge between RJ45 Ethernet cable and your USB A/C devices. The driver-free installation with native driver support in Chrome, Mac, and Windows OS; The USB A/C Ethernet adapter dongle supports important performance features including Wake-on-Lan (WoL), Full-Duplex (FDX) and Half-Duplex (HDX) Ethernet, Crossover Detection, Backpressure Routing, Auto-Correction (Auto MDIX).
  • INCREDIBLE PERFORMANCE - Supports full 10/100/1000Mbps gigabit ethernet performance over USB A/C's 5Gbps bus, faster and more reliable than most wireless connections. Link and Activity LEDs. USB powered, no external power required. Backward compatible with USB 2.0/1.1.✅ To reach 1Gbps, make sure to use CAT6 & up Ethernet cables.
  • BROAD COMPATIBILITY - The USB A/C-Ethernet adapter is compatible with Windows 11/10/8.1/8/7/Vista/XP, Mac OSX 10.6/10.7/10.8/10.9/10.10/10.11/10.12, Linux kernel 3.x/2.6, Android and Chrome OS.Compatible with IEEE 802.3, IEEE 802.3u and IEEE 802.3ab. Supports IEEE 802.3az (Energy Efficient Ethernet).❌Do Not Support Windows RT. (NOT compatible with Nintendo Switch.)
  • 18 MONTH WARRANTY - Exclusive BENFEI Unconditional 18-month Warranty ensures long-time satisfaction of your purchase; Friendly and easy-to-reach customer service to solve your problems timely.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

5. Make a bounded TCP check in Bash

Bash can attempt a TCP connection by opening /dev/tcp/HOST/PORT. In a script, wrap the attempt with timeout so it cannot wait indefinitely:

if timeout 5 bash -c '</dev/tcp/HOST/PORT &>/dev/null'; then
  echo "TCP connection succeeded"
else
  echo "TCP connection failed or timed out"
fi

Substitute the target hostname or IP address and port. This is a compact TCP readiness check, not a port inventory: it does not return Nmap’s scan states or identify a service version. Bash also recognizes /dev/udp, but opening that socket alone does not prove a UDP application is listening.

What a failed check does—and does not—tell you

A refused TCP connection

A refusal usually means the connection attempt was rejected. Check that the service is running and listening on the intended port, then confirm it is bound to an address reachable from the client. A service listening only on loopback cannot accept a connection arriving through another interface.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A timeout or a filtered result

A timeout does not identify its cause. Filtering, routing, an unavailable host, packet loss, or an upstream network rule can all stall an attempt. A filtered Nmap result likewise says the scanner could not determine the port state; it does not prove which device or rule is responsible. Check host reachability and the network path, including host and cloud firewalls, routers, and upstream filters. Firewall rules do not establish that an application is listening.

A successful TCP check

Success confirms only that a TCP connection could be made from the test location. It does not verify TLS negotiation, credentials, application requests, or the service’s behavior after connecting. Test those with the client and request appropriate to the application.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.