How to solve Port 8080 was already in use.

Updated: 2024-04-06

How many times during our development we got this error after pushing the start button?

*************************** 
APPLICATION FAILED TO START 
*************************** 
 
Description: 
 
Web server failed to start. Port 8080 was already in use. 
 
Action: 
 
Identify and stop the process that's listening on port 8080 or configure this application to listen on another port. 
 
 
Process finished with exit code 0 

Sometimes our IDE fail to close the task in the OS and it cannot find anymore what's running on our computer.

How to find and destroy the task

On MacOS and Linux, from the console/terminal you can

lsof -i tcp:8080 

lsof will show the LiSt of Open Files on the open socket (-i) tcp:8080 (for unix systems almost everything is a file).

You will get an answer similar to:

COMMAND   PID  USER   FD   TYPE            DEVICE SIZE/OFF NODE NAME 
java    18902 marco  252u  IPv6 0xe56dd35caa2d493      0t0  TCP *:us-srv (LISTEN) 

at this point you can simply kill 18902 (18902 is the PID found previously).

Find the process in Windows

In Windows you dont have lsofyou can use netstat.

netstat -ano | findstr :8080 

-ano that can be easily remembered if you know a bit of italian ... means:

  • a: Displays all active TCP connections and the TCP and UDP ports on which the computer is listening.
  • n: Displays active TCP connections, addresses and port numbers are expressed numerically.
  • o: Displays active TCP connections and includes the process ID (PID).

You will receive an answer similar to:

TCP    0.0.0.0:8080      0.0.0.0:0      LISTENING       1234 

You can use the Resource Monitor to kill the Process 1234


WebApp built by Marco using SpringBoot 3.2.4 and Java 21, in a Server in Switzerland without 'Cloud'.