SysTutorials

Identifying Which Process Listens on a Port in Linux

· updated April 12, 2026

When your application fails to bind to a port, you need to identify what’s already using it. This is one of the most common debugging tasks in Linux system administration.

Using ss (Modern Approach)

The ss command has largely replaced netstat in modern Linux distributions. It’s faster, more efficient, and provides clearer output:

ss -ltnp | grep :9999

Breaking down the flags:

If you need to check UDP ports as well:

ss -ltnup | grep :9999

For a specific port without grep:

ss -ltnp sport = :9999

You’ll typically need sudo to see process names and PIDs for sockets owned by other users:

sudo ss -ltnp | grep :9999

Using netstat (Legacy Alternative)

If your system still uses netstat, the syntax is similar:

sudo netstat -pln | grep 9999

The flags mean:

Add t for TCP-only or u for UDP-only filtering:

sudo netstat -ptln | grep 9999
sudo netstat -puln | grep 9999

Using lsof

Another useful tool is lsof, which shows open files and network connections:

sudo lsof -i :9999

This gives you the process name, PID, user, and connection status in an easy-to-read format.

Practical Examples

Check what’s listening on port 80:

sudo ss -ltnp | grep :80

Example output:

LISTEN    0      511                0.0.0.0:80              0.0.0.0:*    users:(("nginx",pid=1234,fd=6))

Find all processes listening on any port:

sudo ss -ltnp

Check if a specific service (like PostgreSQL on port 5432) is running:

sudo ss -ltnp | grep :5432

Verify both TCP and UDP listeners on port 53 (DNS):

sudo ss -ltnup | grep :53

Permission Notes

If you run these commands without sudo, you’ll only see processes owned by your current user. System services and processes owned by other users will show as (-) in the output. Always use sudo for complete visibility when troubleshooting port conflicts.

Why ss Over netstat

The netstat command is deprecated in many distributions. ss is part of the iproute2 package and provides superior performance, especially on systems with many connections. If you’re writing scripts or automation for modern systems, prefer ss.

Troubleshooting Common Issues

When encountering problems on Linux systems, follow a systematic approach. Check system logs first using journalctl for systemd-based distributions. Verify service status with systemctl before attempting restarts. For network issues, use ip addr and ss -tulpn to diagnose connectivity problems.

Package management issues often stem from stale caches. Run dnf clean all on Fedora or apt clean on Ubuntu before retrying failed installations. If a package has unmet dependencies, try resolving them with dnf autoremove or apt autoremove.

These commands are frequently used alongside the tools discussed in this article:

Quick Verification

After applying the changes described above, verify that everything works as expected. Run the relevant commands to confirm the new configuration is active. Check system logs for any errors or warnings that might indicate problems. If something does not work as expected, review the steps carefully and consult the official documentation for your specific version.

← All posts