Find out which process is using a port
Sometimes your programs fail because the network port they are trying to use is already in use by some other process.
How to find out what this other process is?
1 answer
Use netstat -lp
.
Typically in such a scenario you will likely be mostly interested in IP sockets, in which case you can also add -A inet,inet6
. To get numerical port numbers, add -n
as well. (See the man page for details.)
Look at the "local address" field to find the port binding in question, and then look at the "PID/Program name" field to determine which application has bound to that port.
The contents of /proc/pid/cmdline and the target of the /proc/pid/exe symlink may help you narrow down which process and invocation that is. pstree pid
can also be helpful. In all three cases, replace the literal "pid" with the actual process ID value as determined from netstat
output.
0 comment threads