If you develop web applications on your local environment, you will notice that the port 8080 is often set as default. Most likely one day you will face a situation where 2 running web servers want to bind the same port: 8080. Obviously, this is not allowed and you will get an error “Address already in use”. In
The best way to sort this conflict is to follow these simple steps.
Step 1: find if a process listen on the port 8080
Open a terminal and enter this command:
sudo lsof -i :8080 | grep LISTEN
If you have already a running server on 8080, then the command will show the application running on this port. N
java 28045 nicolas 125u IPv6 0x609c3697d21f8a2d 0t0 TCP *:http-alt (LISTEN)[/terminal]
Step 2: obtain more information about the process
ps -e {pid} | less
Note that you have to replace the {pid} by the value found in the result of the
PID TTY TIME CMD
28045 ?? 0:13.70 /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/java -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=64979 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=localhost -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -Djava.security.egd=file:/dev/./urandom -noverify -XX:TieredStopAtLevel=1 -Dfile.encoding=UTF-8 -classpath /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/resources.jar:{more libraries…}:/Users/nicolas/.m2/repository/org/springframework/spring-jcl/5.1.4.RELEASE/spring-jcl-5.1.4.RELEASE.jar com.nicolasrabier.whatever.ServerApplication –spring.output.ansi.enabled=always
[/terminal]
Step 3: kill the process
If you can no longer quit safely the web server process, there is still a way to kill
Note in the command you have to replace the {pid} by the value found in the result of the
sudo kill -9 {pid}
After running this command, no process listens on the port 8080 which means that you can start safely the other web server.
Simply just desired to state Now i’m glad I came upon your page!