How to Find Which Process Is Using a Port in Linux
Identify the PID and program listening on a Linux TCP port.
When a server says a port is already in use, identify the owning socket first and inspect the process before acting.
Step by step
1 Check the socket
$ sudo ss -ltnp | grep :3000 Shows listening TCP sockets and process information.
2 Inspect the PID
$ ps -fp 12345 Confirm the program and arguments before stopping anything.
3 Stop a known leftover process
$ kill 12345 SIGTERM asks it to exit cleanly.
Tips worth knowing
- Use sudo when another user owns the process.
- Check containers with `docker ps`.
- Use service managers for production daemons.
Frequently asked questions
How do I check what is using port 3000?
Use `sudo ss -ltnp | grep :3000`.
How do I free a port safely?
Identify and verify the owner, then stop it cleanly or through its service manager.
If it goes wrong
The commands behind it
See listening ports, active connections and which process owns each socket.
psSee what is running, find a process ID, and combine with grep to hunt down a program.
killTerminate processes politely or forcibly — and understand what -9 really does.
Concepts involved: Port · PID (Process ID)
More how-to guides
See how much space is left, and find out what is using it.
Extract a .tar.gz archiveUnpack tar.gz, tar.bz2, tar.xz and zip archives from the command line.
Free a port that is already in useFind which process holds a port and stop it cleanly.
Find and replace text in filesReplace text in one file or across a whole project, safely.