· df · 1 min read

Find process listening on a port

listening processaixrmsockTechnologytcpipprotocol control block+4

How to Find process listening on a port

I recently had an issue while implementing my web-server as the default port was used by something else.
I used below commands in AIX to find more details of that process

1. Use netstat command to find the protocol control block or PCB which is a protocol layer for UDP or TCP sockets

eg.  netstat -Aan | grep <port_number>
netstat -Aan | grep 30501

output will be something like

$ netstat -Aan | grep 30501
f1000e0001363bb8 tcp4     0     0  *.30501     .     LISTEN

2. As “root” user, run rmsock command. Don’t worry it won’t remove anything as specified in the documentation.

usage: rmsock Address TypeofAddress

eg.
rmsock f1000e0001363bb8 tcpcb
output: The socket f1000e0001363bb8 is being held by proccess 15854120 (perl).

You can further diagnose the process using “ps -ef | grep <process_id>” and see the real process.

A good documentation can be found in IBM site which caters for Windows as well.