How to find the process id listening on a port?

On Windows – Example trying to find which process is listening on port 1433

Show if any process is listening on port 1433 for example
c:\temp> netstat -ano | find /I “1433” | find /I “LISTEN”
Proto Local Address Foreign Address State PID
TCP 0.0.0.0:1433 0.0.0.0:0 LISTENING 6244

Using tlist or task manager one can find the PID (last column) from the above command to find the process
c:\temp> tlist | find /I “6244”
6244 sqlservr.exe

On Linux
Using netsat find if any process is listening to port 22
$ netstat -an | grep 22 | grep LISTEN
tcp 0 0 :::22 :::* LISTEN

Using fuser one can find the process id listening on the port, the process id is 3788, one has to be root to see the result
[root@localhost ~]# fuser -v 22/tcp
here: 22

USER PID ACCESS COMMAND
22/tcp root 3788 f…. sshd

Using lsof using the port#, below shows SSH is listening to port and process id is 3788. This command needs to be run as root.
[root@localhost ~]# /usr/sbin/lsof -i :22
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
sshd 3788 root 3u IPv6 8374 TCP *:ssh (LISTEN)

On AIX
https://www-304.ibm.com/support/docview.wss?uid=swg21264632

One thought on “How to find the process id listening on a port?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s