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

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

bind: Address already in use

Something is already listening on the port your program wants.

The commands behind it

ss

See listening ports, active connections and which process owns each socket.

ps

See what is running, find a process ID, and combine with grep to hunt down a program.

kill

Terminate processes politely or forcibly — and understand what -9 really does.

Concepts involved: Port · PID (Process ID)

More how-to guides

Check disk space in Linux

See how much space is left, and find out what is using it.

Extract a .tar.gz archive

Unpack tar.gz, tar.bz2, tar.xz and zip archives from the command line.

Free a port that is already in use

Find which process holds a port and stop it cleanly.

Find and replace text in files

Replace text in one file or across a whole project, safely.