Main Tutorials

Linux – Which application is using port 8080

Always, Java developers need to know which application is using the high demand 8080 port. In this tutorial, we will show you two ways to find out which application is using port 8080 on Linux.

1. lsof + ps command

1.1 Bring up the terminal, type lsof -i :8080


$ lsof -i :8080

COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
java    10165 mkyong   52u  IPv6 191544      0t0  TCP *:http-alt (LISTEN)
Note
If multiple result, try lsof -i :8080 | grep LISTEN

1.2 PID 10165 is using port 8080, type ps -ef | grep 10165 to find out the application details.


$ ps -ef | grep 10165

mkyong   10165  4364  1 11:58 ?        00:00:20 /opt/jdk/jdk1.8.0_66/jre/bin/java 
//...
-Djava.endorsed.dirs=/home/mkyong/software/apache-tomcat-8.0.30/endorsed 
-classpath /home/mkyong/software/apache-tomcat-8.0.30/bin/bootstrap.jar:
/home/mkyong/software/apache-tomcat-8.0.30/bin/tomcat-juli.jar 
-Dcatalina.base=/home/mkyong/.IntelliJIdea15/system/tomcat/Unnamed_hc_2 
-Dcatalina.home=/home/mkyong/software/apache-tomcat-8.0.30 
-Djava.io.tmpdir=/home/mkyong/software/apache-tomcat-8.0.30
/temp org.apache.catalina.startup.Bootstrap start

Answer : IntelliJ IDEA + Tomcat 8 is using the port 8080.

2. netstat + ps command

Just different command to do the same thing.Type netstat -nlp | grep 8080 to get the PID and ps it.


$ netstat -nlp | grep 8080

(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp6       0      0 :::8080                 :::*                    LISTEN      10165/java 

$ ps -ef | grep 10165

mkyong   10165  4364  1 11:58 ?        00:00:20 /opt/jdk/jdk1.8.0_66/jre/bin/java 
//...

References

  1. Wikipedia : Lsof command
  2. Wikipedia : ps command
  3. Wikipedia : netstat command
  4. Mac OSX – What program is using port 8080

About Author

author image
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

Subscribe
Notify of
5 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
charlie arehart
3 years ago

Cool tip. But readers should note that if they use either of these to find ports that are in use by a process you did not start yourself, you won’t see them (with lsof at all, or not completely with netstat), so use sudo, etc to elevate your privs. Worked for me. Thanks, mkyong.

Sameer
1 year ago

Very Very Useful

Abdullah Khawer
1 year ago

Very useful. Thanks a lot. It helped me. 🙂

younes
3 years ago

good thanks

Alex
5 years ago

I have a java process running in 8080, and I cant kill it becuse it automatically restarts.
Do you have any idea of the origin of this process, how to trace it back? Kill it?
It is running from start up, so its not something I have programmed.
Thanks and good post 🙂