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 professionals since 2007

Our laser focus on a single technology has made us a leader in this space. Need help?

  • We build a solid first version of your product
  • We train your development team
  • We rescue your project in trouble
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)