1

On Windows 10, Apache ActiveMQ Artemis 2.11.0 won't start because:

2020-03-28 23:03:04,322 INFO  [org.apache.activemq.artemis.core.server] AMQ221080: Deploying address ExpiryQueue supporting [ANYCAST] 
2020-03-28 23:03:04,322 INFO  [org.apache.activemq.artemis.core.server] AMQ221003: Deploying ANYCAST queue ExpiryQueue on address ExpiryQueue 
2020-03-28 23:03:06,418 ERROR [org.apache.activemq.artemis.core.server] AMQ224000: Failure in initialisation: java.net.BindException: Address already in use: bind
        at sun.nio.ch.Net.bind0(Native Method) [rt.jar:1.8.0_212]
        at sun.nio.ch.Net.bind(Net.java:433) [rt.jar:1.8.0_212]
        at sun.nio.ch.Net.bind(Net.java:425) [rt.jar:1.8.0_212]
        at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) [rt.jar:1.8.0_212]
        at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:130) [netty-all-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:563) [netty-all-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1332) [netty-all-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:488) [netty-all-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:473) [netty-all-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:984) [netty-all-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:259) [netty-all-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:366) [netty-all-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163) [netty-all-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404) [netty-all-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:495) [netty-all-4.1.34.Final.jar:4.1.34.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:905) [netty-all-4.1.34.Final.jar:4.1.34.Final]
        at org.apache.activemq.artemis.utils.ActiveMQThreadFactory$1.run(ActiveMQThreadFactory.java:118) [artemis-commons-2.11.0.jar:2.11.0]
2020-03-28 23:03:06,423 INFO  [org.apache.activemq.artemis.core.server] AMQ221001: Apache ActiveMQ Artemis Message Broker version 2.11.0 [0.0.0.0, nodeID=61904c81-713a-11ea-ad5b-902b34592bce] 
2020-03-28 23:03:06,978 INFO  [org.apache.activemq.hawtio.branding.PluginContextListener] Initialized activemq-branding plugin

I've seen this post, as some others. Problem is that in error I got there is no explicit mention of what port is in use, only:

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

I've tried all suggested solutions but in vain. Also, there is no conf folder or activemq.xml file.

UPDATE: by previous statements I mean taht I already checked and none of ports used by Artemis is already used by some other service/application.

All that I could find is broker.xml file in etc folder of the broker. None of the standard ports are in use. Also tried to disable ICS (Internet Connection Sharing) - no effect at all.

What do I miss here?

Nenad Bulatović
  • 7,238
  • 14
  • 83
  • 113

2 Answers2

2

ActiveMQ 5.x uses conf/activemq.xml, but ActiveMQ Artemis uses etc/broker.xml so what you're seeing there is expected. Ultimately the problem here, as stated on the answer you cited, is that there is either already a broker running or some other service running that is using the port(s) that ActiveMQ wants to bind to.

ActiveMQ Artemis binds to a handful of ports by default. Theses are defined in etc/broker.xml. Here's the default configuration:

<acceptors>
   <acceptor name="artemis">tcp://0.0.0.0:61616??anycastPrefix=jms.queue.;multicastPrefix=jms.topic.;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300</acceptor>
   <acceptor name="amqp">tcp://0.0.0.0:5672?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=AMQP;useEpoll=true;amqpCredits=1000;amqpLowCredits=300</acceptor>
   <acceptor name="stomp">tcp://0.0.0.0:61613?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=STOMP;useEpoll=true</acceptor>
   <acceptor name="hornetq">tcp://0.0.0.0:5445?protocols=HORNETQ,STOMP;useEpoll=true</acceptor>
   <acceptor name="mqtt">tcp://0.0.0.0:1883?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=MQTT;useEpoll=true</acceptor>
</acceptors>

So, by default, the broker ties to bind to these ports:

  • 61616
  • 5672
  • 61613
  • 5445
  • 1883

Any one of these ports may already be in use when you start the broker. It's likely you don't need your broker to listen on all of these ports so I recommend you disable everything except what you absolutely need. If that solves your problem then great, but if not you could use a process of elimination to find the one that's already in use or one of commands from the other answer (e.g. netstat, fuser, etc.). Once you've identified the problematic port then you can either change the broker.xml to use a different port or stop the process that's already using it.

If it's really true that none of the ports are being used then that means there is a bug in a core part of the JVM's networking stack because that is where the exception is coming from. My hunch is that there is no such bug so I recommend using the process of elimination that I mentioned previously. Try commenting out all of the acceptor elements and starting the broker. Since the broker won't try to bind to any ports there should be no exception. Then stop the broker and add one of the acceptor elements back and restart the broker. Do this for each acceptor until the problem re-appears at which point you can change the broker's configuration to use a different port.

Justin Bertram
  • 29,372
  • 4
  • 21
  • 43
1

I am just gonna add this in case someone stumbles across this post and the solution above doesn't work;

I came across this problem while configuring a second broker next to the first one. I got the same problem that Java was throwing java.net.BindException: Address already in use: bind .

The configured acceptor port wasn't in use but the problem was that every broker instance has there own mgmt console. Therefore, this console also needs a port. While configuring the second broker, ActiveMQ set the default console port which is the same as the console port for the first broker.

You need to change the console port in the bootstrap.xml to an unused port too.

Hope this can help some of you :)

Telvanis
  • 55
  • 1
  • 8