Read more

Find out which PID listens on socket

Thomas Eisenbarth
August 31, 2010Software engineer at makandra GmbH

Show all sockets (Unix & TCP/UDP), both listening and established ones:
netstat -anp

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

To limit the output e.g. to listening TCP sockets:
netstat -anp | grep tcp | grep LISTEN
...
tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN 28683/server
...

This means: A tcp v4 socket listening on port 3000 on all IP adresses (0.0.0.0 is synonym to 'all interfaces on the machine').

The last column includes the PID, kill -9 28683 should exit the process and clean up the socket.

Posted by Thomas Eisenbarth to makandra dev (2010-08-31 12:13)