Resolve exception “java.net.BindException: Address already in use”

0Shares

When you run Mule application in Anypoint Studio or deploy Mule application in Mule Runtime, it is common to get the following error:

ERROR 2016-09-05 22:17:57,070 [main] org.mule.module.launcher.application.DefaultMuleApplication: 
********************************************************************************
Message               : Failed to invoke lifecycle phase "start" on object: org.mule.module.http.internal.listener.DefaultHttpListenerConfig@7c1503a3
Element               : /HTTP_Listener_Configuration @ app:bindingerrortesting.xml:9 (HTTP Listener Configuration)
--------------------------------------------------------------------------------
Root Exception stack trace:
java.net.BindException: Address already in use
	at sun.nio.ch.Net.bind0(Native Method)
	at sun.nio.ch.Net.bind(Net.java:433)
	at sun.nio.ch.Net.bind(Net.java:425)
	at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
	at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
	at org.glassfish.grizzly.nio.transport.TCPNIOBindingHandler.bindToChannelAndAddress(TCPNIOBindingHandler.java:131)
	at org.glassfish.grizzly.nio.transport.TCPNIOBindingHandler.bind(TCPNIOBindingHandler.java:88)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.bind(TCPNIOTransport.java:238)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.bind(TCPNIOTransport.java:218)
	at org.glassfish.grizzly.nio.transport.TCPNIOTransport.bind(TCPNIOTransport.java:209)
	at org.mule.module.http.internal.listener.grizzly.GrizzlyServer.start(GrizzlyServer.java:41)
	at org.mule.module.http.internal.listener.DefaultHttpListenerConfig.start(DefaultHttpListenerConfig.java:274)
	at sun.reflect.GeneratedMethodAccessor12.invoke(Unknown Source)

The reason behind the error is some other application is already running with the same port and so you cannot run current application with the same port.

If you are using Windows OS, then go to command prompt and run the following command:

netstat -a -n -p tcp -b

This will list all services running, protocol used and other details.

If needed, stop the other application that is running on the same port. If possible, change your application’s port number. If multiple Mule applications needs to run on the same host and port, then use Domain Project and create listener/request configurations in the Domain project and let your apps support the Domain project. This will fix the binding clashes.

Hope this helps in fixing the issue.

0Shares