Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Address already in use: bind" when running Spring Boot application

Tags:

spring-boot

I have a problem with running my sample Spring Boot Application. When I try to run it, this error occurs:

 java.net.BindException: Address already in use: bind
            at sun.nio.ch.Net.bind0(Native Method)
            at sun.nio.ch.Net.bind(Unknown Source)
            at sun.nio.ch.Net.bind(Unknown Source)
            at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
            at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
            at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:473)
o.apache.catalina.core.StandardService   : Failed to initialize connector [Connector[org.apache.coyote.http11.Http11NioProtocol-8080]]

    org.apache.catalina.LifecycleException: Failed to initialize component [Connector[org.apache.coyote.http11.Http11NioProtocol-8080]]
            at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:106)
            at org.apache.catalina.core.StandardService.initInternal(StandardService.java:559)
            at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
            at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:814)
            at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:102)
            at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:139)
            at org.apache.catalina.startup.Tomcat.start(Tomcat.java:335)
            at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:57)
            at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.<init>(TomcatEmbeddedServletContainer.java:52)
            at 
like image 340
reza ramezani matin Avatar asked Jan 15 '16 05:01

reza ramezani matin


People also ask

How do I resolve an address that is already in use error?

When this EADDRINUSE issue has already happened, in order to resolve it, you need to kill the process manually. In order to do that, you need to find the process id (PID) of the process. You know the process is occupying a particular port on your machine or server.

Can we run spring boot application without application properties?

We have a Spring Boot application which we are looking to deploy without an application. properties file in the jar. The application. properties file will be excluded when the jar is built using the maven jar plugin.

What is Java net BindException?

Signals that an error occurred while attempting to bind a socket to a local address and port. Typically, the port is in use, or the requested local address could not be assigned.


2 Answers

Is it ok the first time you run it, and run it again you get an error? If this is the case, You need to stop service before running again. Here is a way to stop. Click the stop button that looks like this:

enter image description here

like image 198
Sang9xpro Avatar answered Jan 02 '23 20:01

Sang9xpro


"Address already in use" means, there is already another application running on port 8080. Use your OS tools to find that process and end it, before you start your application, or let your application run on another port. If you use an embedded server in your Boot application, you can specify the following property:

server.port=8085 

Of course you can choose whatever port you want.

like image 30
dunni Avatar answered Jan 02 '23 21:01

dunni