java.net.BindException: Address already in use

1,548 views
Skip to first unread message

venkatesh rasipuram

unread,
Dec 17, 2018, 1:19:10 AM12/17/18
to wiremock-user
I am getting this error while executing the jar in the linux machine. 

log4j:WARN No appenders could be found for logger (org.eclipse.jetty.util.log).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" com.github.tomakehurst.wiremock.common.FatalStartupException: java.lang.RuntimeException: java.net.BindException: Address already in use
        at com.github.tomakehurst.wiremock.WireMockServer.start(WireMockServer.java:145)
        at com.wm.gif.qc.mock.QCMock.startServer(QCMock.java:41)
        at com.wm.gif.qc.mock.QCMock.main(QCMock.java:17)
Caused by: java.lang.RuntimeException: java.net.BindException: Address already in use
        at com.github.tomakehurst.wiremock.jetty9.JettyHttpServer.start(JettyHttpServer.java:132)
        at com.github.tomakehurst.wiremock.WireMockServer.start(WireMockServer.java:143)
        ... 2 more
Caused by: java.net.BindException: Address already in use
        at sun.nio.ch.Net.$$YJP$$bind0(Native Method)
        at sun.nio.ch.Net.bind0(Net.java)
        at sun.nio.ch.Net.bind(Net.java:436)
        at sun.nio.ch.Net.bind(Net.java:428)
        at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
        at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
        at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:317)
        at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
        at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:235)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.eclipse.jetty.server.Server.doStart(Server.java:390)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at com.github.tomakehurst.wiremock.jetty9.JettyHttpServer.start(JettyHttpServer.java:130)
        ... 3 more

I have used the below code.  can you please help me?

{code}
public void startServer(){
WireMock.configureFor(8080);
server = new WireMockServer(WireMockConfiguration.wireMockConfig().port(8080).containerThreads(100).jettyAcceptors(50).extensions(new BodyTransformer()));
server.start();
}
{code}

Anne kootstra

unread,
Dec 18, 2018, 1:39:34 PM12/18/18
to wiremock-user
In this case it would mean port 8080 is already in use by another application. Try another port like 8787 or 8009? 

Kind regards,

Anne

Op maandag 17 december 2018 07:19:10 UTC+1 schreef venkatesh rasipuram:
Reply all
Reply to author
Forward
0 new messages