Skip to content
Advertisement

Why after that I quit a Spring Boot application in a Linux shell (by CTRL+Z) a process still listen on the 8080 port? (the port used by my application

I am working on a Spring Boot application running it on a Linux machine. It is a batch application containing Spring Boot Admin tool listening on the 8080 port.

I have the following “problem”: I run it into my shell for the first time using this command:

mvn spring-boot:run

it correctly start and I can access to the Spring Boot Admin tool panel at this address http://localhost:8080/

Supse that I stop my batch application execution clicking CTRL+Z on my keyboard, so the Spring Boot application is now stopped and I obtain this output message:

[1]+  Stopped                 mvn spring-boot:run

Ok, now if I run again my application by the same start command:

mvn spring-boot:run

now I am obtaining this error message:

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.

So if I perform this command to find the process that is listening on port 8080:

andrea@ubuntu:~/git/notartel-api-batch$ netstat -ltnp | grep -w ':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       2      0 :::8080                 :::*                    LISTEN      16269/java     

If now that I killed the previous process I restart again my Spring Boot application it will be started without problem.

Why if I quit a Spring Boot application listening on the 8080 port (using CTRL+Z into the Linux shell), this process still listen on this port? I expected that the entire application will be killed and that nothing listen on the port

Advertisement

Answer

Ctrl + Z doesn’t kill the application but suspend it and put it in background, use Ctrl + C if you want to abort the running application.

Advertisement