Written by 00:49 Linux, Server Management

Find PID Listening on an IP Address and Port

10cb973d c0cd 47ac 8ab5 3e9e4ebb9630

Find PID Listening on an IP Address and Port

On Linux, you can use the netstat command to discover which process (and its PID) is listening on a specific IP address and port. Follow the steps below.

1. Basic Command

sudo netstat -tunlp | grep <IP_ADDRESS>
  • Replace <IP_ADDRESS> with the actual IP you want to check. For example: grep 192.168.1.10

2. Command Options

  • -t: Show only TCP connections
  • -u: Show only UDP connections
  • -n: Display addresses and ports numerically without name resolution
  • -l: Show only listening sockets
  • -p: Show the PID/Program name using each socket

3. Example Output

tcp   0   0   192.168.1.10:34001   0.0.0.0:*   LISTEN   2759984/nginx
FieldMeaning
tcpProtocol (TCP)
192.168.1.10:34001Local IP and port
LISTENSocket state
2759984/nginxPID=2759984, process name=nginx

4. Terminate the Discovered PID

sudo kill 2759984

For a forceful kill (SIGKILL):

sudo kill -9 2759984

5. Alternative: ss Command

The ss tool is faster and provides similar information:

sudo ss -tunlp | grep 192.168.1.10

In summary, these commands help you quickly identify which process is listening on a given IP address and port, and allow you to terminate it if needed.

Visited 14 times, 1 visit(s) today
Close