Read more

netstat: How to show listening ports

Daniel Straßner
January 15, 2018Software engineer at makandra GmbH

Sometimes it's necessary for you to check which ports are in use on your local machine and which process is using it. To list this information you can use the following command (which is pretty easy to memorize for Germans 🌷):

sudo netstat -tulpn
  • t: tcp
  • u: udp
  • l: listening ports
  • p: process
  • n: network
Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

Use sudo to see the name of the process.

Finding open ports in the netstat output

You should look for rows with State: LISTEN.

Rows for local address 127.0.0.1 or ::1 (IPv6) can only be reached from your own PC:

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 127.0.0.1:3000          0.0.0.0:*               LISTEN      9630/ruby 

Rows for local address 0.0.0.0 can be reached from other PCs on your network:

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:3000            0.0.0.0:*               LISTEN      7999/ruby
Posted by Daniel Straßner to makandra dev (2018-01-15 13:54)