I'd like to be able to find out which process is currently using a certain port in Linux. Is there any way to do this?

  • 3
    On Windows, the command is : netstat -anb – djangofan Dec 11 '09 at 21:39

You have a couple of options:

lsof -i tcp:80

will give you the list of processes using tcp port 80.


sudo netstat -nlp

will give you all open network connections.

  • 2
    lsof -i | grep {username} is also very useful, i.e. lsof -i | grep apache – LawrenceC Oct 30 '11 at 3:20
  • 1
    For anyone wondering, -n : don't resolve names, -l : display listening server sockets, -p : display PID/Program name for sockets. – yellavon May 12 '14 at 15:18
  • I usually add -P to lsof -i tcp:$PORTNUMBER so that the port gets printed back to me as a number. – js. Jun 23 '15 at 8:42
netstat -lp
  • 4
    on mac you have to add a protocol option to -p. so something like: netstat -lp tcp. – vrish88 May 25 '10 at 14:59

I am using "CentOS 7 minimal" which has nor netstat neither lsof. But a lot of linux distributions have the socket statistics command (i.e. ss).

Here is an example of execution:

# ss -tanp | grep 6379
LISTEN   0    128   *:*   users:(("redis-server",pid=2531,fd=4))

In Linux, To find a process running on a port, do below:

lsof -i :<port_number>


lsof -i :8080
  • Thanks for trying to help. This command was mentioned in the accepted answer. If you have something new, please edit your post. – Ben N Jan 6 '16 at 0:22

also if you want to list running processes that are speaking TCP you can use

sudo netstat -tnp

    sudo to get processes you don't own
    -t for TCP
    -n for numeric
    -p for pid

to get processes speaking UDP replace the -t with a -u

sudo netstat -unp

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.