Spring Boot - BindException Address already in use bind

By Yashwant Chavan, Views 85556, Last updated on 14-Apr-2019

when I execute the Application.java I am getting java.net.BindException: Address already in use: bind exception. I am using windows platform and I have properly terminated the Application.java thru Eclipse each time. But still I am getting same error when I execute the program next time.

tags spring-boot bindexception tomcat

Application.java

package com.technicalkeeda;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableAutoConfiguration
@ComponentScan
public class Application {
 public static void main(String[] args) {
  SpringApplication.run(Application.class, args);
 }

}

java.net.BindException: Address already in use: bind


  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.1.3.RELEASE)

2014-09-27 08:59:45.160  INFO 6824 --- [           main] com.technicalkeeda.bean.Application      : Starting Application on swami-samartha with PID 6824 (C:\javaworkspace\SpringBootExamples\bin started by swami in C:\javaworkspace\SpringBootExamples)
2014-09-27 08:59:45.188  INFO 6824 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@1fddc31: startup date [Sat Sep 27 08:59:45 IST 2014]; root of context hierarchy
2014-09-27 08:59:45.497  INFO 6824 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'beanNameViewResolver': replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2014-09-27 08:59:46.116  INFO 6824 --- [           main] .t.TomcatEmbeddedServletContainerFactory : Server initialized with port: 8080
2014-09-27 08:59:46.238  INFO 6824 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2014-09-27 08:59:46.238  INFO 6824 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/7.0.54
2014-09-27 08:59:46.806  INFO 6824 --- [ost-startStop-1] o.a.c.c.C.[.[.[/SpringBootExamples]      : Initializing Spring embedded WebApplicationContext
2014-09-27 08:59:46.807  INFO 6824 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1619 ms
2014-09-27 08:59:47.238  INFO 6824 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean        : Mapping servlet: 'dispatcherServlet' to [/]
2014-09-27 08:59:47.240  INFO 6824 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2014-09-27 08:59:47.291 ERROR 6824 --- [           main] o.a.coyote.http11.Http11NioProtocol      : Failed to start end point associated with ProtocolHandler ["http-nio-8080"]

java.net.BindException: Address already in use: bind
 at sun.nio.ch.Net.bind(Native Method)
 at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:119)
 at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59)
 at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:473)
 at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:647)
 at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:449)
 at org.apache.catalina.connector.Connector.startInternal(Connector.java:1007)
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
 at org.apache.catalina.core.StandardService.startInternal(StandardService.java:459)
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
 at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:731)
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
 at org.apache.catalina.startup.Tomcat.start(Tomcat.java:341)
 at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:79)
 at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.(TomcatEmbeddedServletContainer.java:69)
 at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:289)
 at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:146)
 at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:159)
 at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:132)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476)
 at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120)
 at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:683)
 at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
 at com.technicalkeeda.bean.Application.main(Application.java:14)

2014-09-27 08:59:47.292 ERROR 6824 --- [           main] o.apache.catalina.core.StandardService   : Failed to start connector [Connector[org.apache.coyote.http11.Http11NioProtocol-8080]]

org.apache.catalina.LifecycleException: Failed to start component [Connector[org.apache.coyote.http11.Http11NioProtocol-8080]]
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
 at org.apache.catalina.core.StandardService.startInternal(StandardService.java:459)
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
 at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:731)
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
 at org.apache.catalina.startup.Tomcat.start(Tomcat.java:341)
 at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:79)
 at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.(TomcatEmbeddedServletContainer.java:69)
 at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:289)
 at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:146)
 at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:159)
 at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:132)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476)
 at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120)
 at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:683)
 at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
 at com.technicalkeeda.bean.Application.main(Application.java:14)
Caused by: org.apache.catalina.LifecycleException: service.getName(): "Tomcat";  Protocol handler start failed
 at org.apache.catalina.connector.Connector.startInternal(Connector.java:1014)
 at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
 ... 16 common frames omitted
Caused by: java.net.BindException: Address already in use: bind
 at sun.nio.ch.Net.bind(Native Method)
 at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:119)
 at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:59)
 at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:473)
 at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:647)
 at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:449)
 at org.apache.catalina.connector.Connector.startInternal(Connector.java:1007)
 ... 17 common frames omitted

2014-09-27 08:59:47.293  INFO 6824 --- [           main] o.apache.catalina.core.StandardService   : Stopping service Tomcat
2014-09-27 08:59:47.366  INFO 6824 --- [           main] .b.l.ClasspathLoggingApplicationListener : Application failed to start with classpath: [file:/C:/javaworkspace/SpringBootExamples/bin/, file:/C:/gradle-2.0/caches/modules-2/files-2.1/aopalliance/aopalliance/1.0/235ba8b489512805ac13a8f9ea77a1ca5ebe3e8/aopalliance-1.0.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.1.2/b316e9737eea25e9ddd6d88eaeee76878045c6b2/logback-classic-1.1.2.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/ch.qos.logback/logback-core/1.1.2/2d23694879c2c12f125dac5076bdfd5d771cc4cb/logback-core-1.1.2.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-annotations/2.3.0/f5e853a20b60758922453d56f9ae1e64af5cb3da/jackson-annotations-2.3.0.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.3.3/7d8c5d79cc99995e21e6f955857312d8409f02a1/jackson-core-2.3.3.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-databind/2.3.3/63b77400b5f1cf83a81823562c48d3120ef5518e/jackson-databind-2.3.3.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/com.fasterxml/classmate/1.0.0/434efef28c81162b17c540e634cffa3bd9b09b4c/classmate-1.0.0.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/javax.validation/validation-api/1.1.0.Final/8613ae82954779d518631e05daa73a6a954817d5/validation-api-1.1.0.Final.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/org.apache.tomcat.embed/tomcat-embed-core/7.0.54/874cb56db3ccd8101d9373f433d86f1badb5dada/tomcat-embed-core-7.0.54.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/org.apache.tomcat.embed/tomcat-embed-el/7.0.54/3c9425b650ba700ac47185500facabd9ab970adc/tomcat-embed-el-7.0.54.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/org.apache.tomcat.embed/tomcat-embed-jasper/7.0.54/54c2b4c25fb5ea0a6edf555986927b20cf9f2aa7/tomcat-embed-jasper-7.0.54.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/org.apache.tomcat.embed/tomcat-embed-logging-juli/7.0.54/68a1a1fc9fa2c7f97431a36e89f95c5d2eb2ebd5/tomcat-embed-logging-juli-7.0.54.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/org.eclipse.jdt.core.compiler/ecj/P20140317-1600/5e329ddb97816f4e5599578aafe87cc07a1381cd/ecj-P20140317-1600.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/org.hibernate/hibernate-validator/5.0.3.Final/e0fa071d3ced426a05fc1a59d788cb72a1659c3c/hibernate-validator-5.0.3.Final.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/org.jboss.logging/jboss-logging/3.1.1.GA/7fb1a7eb7ff1d15cac1802510fee65c7ca31a869/jboss-logging-3.1.1.GA.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/org.slf4j/jcl-over-slf4j/1.7.7/56003dcd0a31deea6391b9e2ef2f2dc90b205a92/jcl-over-slf4j-1.7.7.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/org.slf4j/jul-to-slf4j/1.7.7/def21bc1a6e648ee40b41a84f1db443132913105/jul-to-slf4j-1.7.7.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/org.slf4j/log4j-over-slf4j/1.7.7/d521cb26a9c4407caafcec302e7804b048b07cea/log4j-over-slf4j-1.7.7.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/org.slf4j/slf4j-api/1.7.7/2b8019b6249bb05d81d3a3094e468753e2b21311/slf4j-api-1.7.7.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-autoconfigure/1.1.3.RELEASE/79f68aee72c7b38a5a4c9a4f9047bcee6f39f9db/spring-boot-autoconfigure-1.1.3.RELEASE.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter-logging/1.1.3.RELEASE/9f42f0ea9bb8f62bc5a06d6fcfa68db15bb93fa6/spring-boot-starter-logging-1.1.3.RELEASE.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter-tomcat/1.1.3.RELEASE/88d1185a7364076fb2fd6605527f72a79d4b27e9/spring-boot-starter-tomcat-1.1.3.RELEASE.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter-web/1.1.3.RELEASE/46ad4c385d2fac91385cc9dc090da32d59ec16e5/spring-boot-starter-web-1.1.3.RELEASE.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/org.springframework.boot/spring-boot-starter/1.1.3.RELEASE/e633fa52d5a3c2f664c460bd726e253724b62fe6/spring-boot-starter-1.1.3.RELEASE.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/org.springframework.boot/spring-boot/1.1.3.RELEASE/fab9a7ae9dbe7321a3e28c9882d6dda5caff883/spring-boot-1.1.3.RELEASE.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/org.springframework/spring-aop/4.0.5.RELEASE/d22abbbba78f7c8854fc39346cc99362272c5c90/spring-aop-4.0.5.RELEASE.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/org.springframework/spring-beans/4.0.5.RELEASE/11e00022f109653ee0dbe16b59c26e19bd90fa08/spring-beans-4.0.5.RELEASE.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/org.springframework/spring-context/4.0.5.RELEASE/98cd9a4b8bb0c695c0cfcc204cf804f433851cfe/spring-context-4.0.5.RELEASE.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/org.springframework/spring-core/4.0.5.RELEASE/cce94116431b5a1384d58316a4090bbe7718fd5a/spring-core-4.0.5.RELEASE.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/org.springframework/spring-expression/4.0.5.RELEASE/d7ddbc320c31c15cb3612ed64607e181c3b2d851/spring-expression-4.0.5.RELEASE.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/org.springframework/spring-web/4.0.5.RELEASE/1819f6d4ab65fb33e19c492d5c5aa21396e42b3f/spring-web-4.0.5.RELEASE.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/org.springframework/spring-webmvc/4.0.5.RELEASE/2459455b0f2e19e7a51fc7bff4de341947d9bc57/spring-webmvc-4.0.5.RELEASE.jar, file:/C:/gradle-2.0/caches/modules-2/files-2.1/org.yaml/snakeyaml/1.13/73cbb494a912866c4c831a178c3a2a9169f4eaad/snakeyaml-1.13.jar]
2014-09-27 08:59:47.367 ERROR 6824 --- [           main] o.s.boot.SpringApplication               : Application startup failed

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
 at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:135)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476)
 at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120)
 at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:683)
 at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
 at com.technicalkeeda.bean.Application.main(Application.java:14)
Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
 at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:116)
 at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.(TomcatEmbeddedServletContainer.java:69)
 at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:289)
 at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:146)
 at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:159)
 at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:132)
 ... 5 common frames omitted
Caused by: java.lang.IllegalStateException: Tomcat connector in failed state
 at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:112)
 ... 10 common frames omitted

Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
 at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:135)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476)
 at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:120)
 at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:683)
 at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
 at com.technicalkeeda.bean.Application.main(Application.java:14)
Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
 at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:116)
 at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.(TomcatEmbeddedServletContainer.java:69)
 at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getTomcatEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:289)
 at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:146)
 at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:159)
 at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:132)
 ... 5 more
Caused by: java.lang.IllegalStateException: Tomcat connector in failed state
 at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer.initialize(TomcatEmbeddedServletContainer.java:112)
 ... 10 more

Solution

Checked windows task manager and found that multiple javaw.exe instances are running, So I killed one by one except Eclipse instance process. After that I tried to re-run the Application.java. Now Its working fine for me. But still I am not able to find out the permanent solution. Dear users if you have any solution please post your answer in comment section.

java instance on window task manager

You can find more information on this exception. Refer issue # Spring Boot 773

Solution

Configure another port number 9090 in /src/main/resources/application.properties

server.port=9090
Yashwant

Yashwant

Hi there! I am founder of technicalkeeda.com and programming enthusiast. My skills includes Java,J2EE, Spring Framework, Nodejs, PHP and lot more. If you have any idea that you would want me to develop? Lets connect: yashwantchavan[at][gmail.com]