How to find out which Port number a process is using

32,182

Solution 1

This is how I found a solution:

     » lsof -i -P  | grep node
    node      14489 me   12u  IPv4 0x...      0t0    TCP *:4000 (LISTEN)

Also if i knew the port and I was looking for the process name I would:

     » lsof -i :4000
    COMMAND   PID       USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
    node    14489 me   12u  IPv4 0x...      0t0  TCP *:terabase (LISTEN)

Solution 2

Active Internet connections (w/o servers)

netstat -pnt 

Active Internet connections (only servers)

netstat -pntl
Share:
32,182
Tim Truston
Author by

Tim Truston

Software Engineer, UI/UX Designer.

Updated on July 05, 2022

Comments

  • Tim Truston
    Tim Truston almost 2 years

    I want to be able to find out which port number a process is and filtering the results using a keyword.

    For example, I may want to quickly find out which port numbers are being used by "node" js apps.

    This did not work:

    netstat tulnap | grep "node"
    

    This did not return the port numbers:

    ps aux | grep node