TL;DR
Checking TCP or UDP ports on your devices (or those trying to connect to them) helps you confirm services are running as expected, identify potential security issues, and troubleshoot network connectivity problems. It’s a basic but powerful diagnostic tool.
Why Check Ports?
Think of ports like doors on a building. Each service (like a web server or email program) listens for connections on a specific door (port number). Checking these ‘doors’ tells you if the service is available and responding.
1. Confirming Services are Running
- What it does: Verifies that an application listening on a port is active and accepting connections.
- How to do it (using
netstat): On most Linux systems, use the following command in your terminal:netstat -tulnp | grepReplace <port_number> with the port you want to check. If the service is running, you’ll see information about it (process ID, program name).
- How to do it (using
ss): A more modern alternative to netstat:ss -tulnp | grepAgain, replace <port_number> with the port you’re interested in.
- How to do it (using
telnet): Try connecting to the port:telnetIf successful, you’ll get a connection message. If not, it indicates the service isn’t listening or is blocked.
2. Identifying Potential Security Issues
- Unexpected open ports: If you find a port open that shouldn’t be, it could indicate malware or an unauthorized application running on your system. Investigate immediately!
- Port scanning: Regularly scan your systems for open ports to identify vulnerabilities. Tools like Nmap are commonly used (see Step 4).
- Firewall rules: Checking port status helps confirm that your firewall is correctly blocking unwanted access.
3. Troubleshooting Network Connectivity
- Connection refused: If you can’t connect to a service, checking the port confirms if it’s actively listening. A ‘connection refused’ error often means the service isn’t running or is blocked by a firewall.
- Timeout errors: Similar to connection refused, timeouts suggest the service isn’t reachable on that port.
- Remote access issues: When troubleshooting remote desktop or other remote access tools, verifying the correct port is open on both ends is crucial.
4. Tools for Port Checking
- Nmap: A powerful network scanner used to discover hosts and services on a computer network.
nmap -pReplace <port_number> with the port you want to scan, and <hostname_or_IP> with the target address.
- Online Port Scanners: Many websites offer free online port scanning tools (search for ‘online port scanner’). Be cautious about using these with sensitive systems.
5. TCP vs UDP – What’s the Difference?
TCP (Transmission Control Protocol) is connection-oriented, meaning it establishes a reliable connection before sending data. UDP (User Datagram Protocol) is connectionless and faster but less reliable.
- TCP: Used for applications requiring guaranteed delivery of data (e.g., web browsing, email).
- UDP: Used for applications where speed is more important than reliability (e.g., streaming video, online gaming).
When checking ports, you need to specify whether you’re looking for TCP or UDP services.

