Display apps and occupied ports (Linux)

PROBLEM: My app is not starting, because port is already in use!
SOLUTION: Find it and kill it 🙂

netstat -tulpn

Will provide nice table with all info you migh like, truncated outpus below:

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.1:9770          0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.1:5940          0.0.0.0:*               LISTEN      -                   
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      -    

sudo ss -tulpn

More fresh, more detailed (i like it more than netstat)

Netid          State            Recv-Q           Send-Q                       Local Address:Port                        Peer Address:Port                                                                           
udp            UNCONN           0                0                              224.0.0.251:5353                             0.0.0.0:*               users:(("chrome",pid=3222,fd=260))                             
udp            UNCONN           0                0                              224.0.0.251:5353                             0.0.0.0:*               users:(("chrome",pid=3269,fd=131))  

Now you can find what is “eating” your ports and you are able to debug errors 🙂

Note: If you cannot see the PID, use sudo to execute the command