Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
2  
On Windows, the command is : netstat -anb –  djangofan Dec 11 '09 at 21:39

2 Answers 2

up vote 66 down vote accepted

You have a couple of options:

lsof -i tcp:80

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

Alternatively,

sudo netstat -nlp

will give you all open network connections.

share|improve this answer
1  
lsof -i | grep {username} is also very useful, i.e. lsof -i | grep apache –  ultrasawblade Oct 30 '11 at 3:20
1  
@nagul: You sir, are a hero. –  Abe Petrillo Dec 14 '12 at 12:57
1  
For anyone wondering, -n : don't resolve names, -l : display listening server sockets, -p : display PID/Program name for sockets. –  yellavon May 12 at 15:18
netstat -lp
share|improve this answer
3  
on mac you have to add a protocol option to -p. so something like: netstat -lp tcp. –  vrish88 May 25 '10 at 14:59
    
On linux, -p lists the process owning the socket. –  Jürgen Strobel Sep 28 '11 at 21:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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