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
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 12:54)