How to find the process id (Status of Server) listening on a port?

On Windows:
C:netstat at ; netstat /?
It will display protocol statistics and current TCP/IP network connections.
C:netstat -a -n
It will display all connection and listening port along with address and port number in numeric form.
C:> netstat -ano | find /I “1521” | find /I “LISTEN”
Trying to find which process is listening on particular port 1521. It will Show if any process is listening on port 1521 such as:
Proto Local Address Foreign Address State PID
C:netstat -e -s
It will display your Ethernet statistics.
C:netstate -a -o
It will display process id associated with each process.
C:netstate -v -b
It will display component involved in creating the connection and listening port for all executable.
On Linux:
Using netsat find if any process is listening to any port.
$ netstat -anp | grep <port number>
$ netstat -anp | grep <port number>
This shows the PID and the program name that uses the port. The command must be run as root.
# netstat -anp | grep 12345
# netstat -anp | grep 12345
tcp    0   0*    LISTEN   6629/ssh
tcp    0   0 ::1:12345              :::*    LISTEN   6629/ssh
ssh with the PID 6629 is using the port. Find more info about it.
# ps -efl | grep 6629
4 S root      6629 29716  0  75   0 –  6976 –      14:05 pts/4    00:00:00 ssh testserver -D 12345 -l db2inst1
0 S root      7648  7302  0  78   0 –   742 pipe_w 14:07 pts/7    00:00:00 grep 6629

In this case, the user db2inst1 is deliberately using the port 12345 by specifying -D option of ssh.

[root@localhost ~]# fuser -n tcp <port number>
Using fuser you can find the process id listening on the port.
1. netstat -Aan | grep <port number>
This shows if the specified <port number> is being used. The hex number in the first column is the address of protocol control block (PCB)
2. rmsock <addr of PCB> tcpcb
This shows the process who is holding the socket. Note: This command must be run as root..
$ netstat -Aan | grep 30542
f10000f303321b58 tcp4     0     0  *.30542     *.*     LISTEN

For more information visit the link:


Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s