Activemq can't run due to address already in use error
Asked Answered
O

17

26

How to solve the error?

Java Runtime: Oracle Corporation 1.7.0_05 E:\Program Files\Java\jdk1.7.0_05\jre
  Heap sizes: current=1004928k  free=994439k  max=1004928k
    JVM args: -Dcom.sun.management.jmxremote -Xms1G -Xmx1G -Djava.util.logging.config.file=logging.properties -Dactivemq.classpath=F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\..\conf;F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\../conf;F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\../conf; -Dactivemq.home=F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\.. -Dactivemq.base=F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\.. -Dactivemq.conf=F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\..\conf -Dactivemq.data=F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\..\data -Djava.io.tmpdir=F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\..\data\tmp
ACTIVEMQ_HOME: F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\..
ACTIVEMQ_BASE: F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\..
ACTIVEMQ_CONF: F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\..\conf
ACTIVEMQ_DATA: F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\..\data
Loading message broker from: xbean:activemq.xml
 INFO | Refreshing org.apache.activemq.xbean.XBeanBrokerFactory$1@2b9f7952: startup date [Sat Jul 28 18:10:38 CST 2012]; root of context hierarchy
 INFO | PListStore:[F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\..\data\localhost\tmp_storage ] started
 INFO | Using Persistence Adapter: KahaDBPersistenceAdapter[F:\workspace\Eclipse java\destinytalk\DestinyServer\apache-activemq-5.6.0\bin\..\data\kahadb]
 INFO | KahaDB is version 4
 INFO | Recovering from the journal ...
 INFO | Recovery replayed 1 operations from the journal in 0.071 seconds.
 INFO | ActiveMQ 5.6.0 JMS Message Broker (localhost) is starting
 INFO | For help or more information please see: http://activemq.apache.org/
ERROR | Failed to start ActiveMQ JMS Message Broker (localhost, null). Reason: java.io.IOException: Transport Connector could not be registered in JMX: Failed to bind to server socket: tcp://0.0.0.0:61616 due to: java.net.BindException: Address already in use: JVM_Bind
java.io.IOException: Transport Connector could not be registered in JMX: Failed to bind to server socket: tcp://0.0.0.0:61616 due to: java.net.BindException: Address already in use: JVM_Bind
    at org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:27)
    at org.apache.activemq.broker.BrokerService.registerConnectorMBean(BrokerService.java:1836)
    at org.apache.activemq.broker.BrokerService.startTransportConnector(BrokerService.java:2327)
    at org.apache.activemq.broker.BrokerService.startAllConnectors(BrokerService.java:2243)
    at org.apache.activemq.broker.BrokerService.start(BrokerService.java:551)
    at org.apache.activemq.xbean.XBeanBrokerService.afterPropertiesSet(XBeanBrokerService.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1544)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1485)
Oneill answered 28/7, 2012 at 10:33 Comment(2)
You should add some more context when asking a question.Sniggle
Did any of these answers help you? You should accept one if so.Neoprene
L
37

If you are using Windows 7, please try to disable "Internet Connection Sharing (ICS)" service.

Lorraine answered 17/7, 2013 at 8:25 Comment(4)
Although other answers help you solve the problem in a generic way, I found that this was the problem. ICS runs on same port than AMQ, so if you try to share your connection, say with your mobile, and then use AMQ you will find this error, for no apparent reason.Variolous
I had the same issue and I can confirm that this answer helped me solve the problem too.Brominate
Works like a charm in my Windows 7 system. Click here for the guide.Fabria
I had the same issue with Windows 11. Stopping it resolve the problem for me.Mosera
F
19

Go to installation_folder/conf folder and open up activemq.xml file. On the file look for transport connectors. You can change the port value from there. I changed it to 6616 from 61616. I could not see what process was using it in windows by running netstat -ao command.

<transportConnectors>
        <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
        <transportConnector name="openwire" uri="tcp://0.0.0.0:6616?maximumConnections=1000&amp;wireformat.maxFrameSize=104857600"/>
    </transportConnectors>
Fantastic answered 6/1, 2013 at 6:25 Comment(3)
In my case, it was Visual Studio that was using the port. Closing it removed the error. Best to open other applications after all servers are started.Martamartaban
Plus 1 for mentioning the configuration file.Bullfighter
My issue was the mqtt:// connection, but changing the port on that one fixed it.Gilpin
C
9

I faced the same problem with the error being:

ERROR | Failed to start ActiveMQ JMS Message Broker (localhost, null). Reason: java.io.IOException: Transport Connector could not be registered in JMX: Failed to bind to server socket: tcp://0.0.0.0:61616 due to: java.net.BindException: Address already in use

Following steps maybe useful:

  1. find the process id that is using this port (in your case, 61616). In command promt write: netstat -a -o -n and look at the process id.
  2. Next kill the process from Task Manager or taskkill /F /PID "process id"

http://sourcecode-kk.blogspot.in/2013/02/kill-process-running-on-certain-port-in.html

Cheers.

Carty answered 5/11, 2014 at 9:13 Comment(0)
S
6

The error is telling you that there is either already a broker running or some other service running that is using the required ports that ActiveMQ want to bind its TCP transport and JMX service to. You can see this in the error string "Failed to bind to server socket: tcp://0.0.0.0:61616 due to: java.net.BindException: Address already in use:" and "Transport Connector could not be registered in JMX: Failed to bind to server socket: tcp://0.0.0.0:61616 due to: java.net.BindException: Address already in use:"

To resolve the issue you need to figure out what is running that is using those ports, or change the config to use other ports

Sniggle answered 28/7, 2012 at 11:12 Comment(2)
i had error with other ports "61613" and "61614" i changed them to "6613" and "6614" it worked well for mePenitent
I wonder why ActiveMQ uses such high port numbers by default; at this high range, the ports are essentially randomly picked up by any application that needs a temporary port.Cauthen
S
3

find the process id using the port number from error logs.

fuser [port number]/tcp

then use kill -9 [pid] to kill that process.

Saponin answered 2/2, 2016 at 20:17 Comment(0)
P
2

I had the same issue and it seems the port is blocked by another JVM using AMQ connection (ServiceMix as a client of the AMQ service).

Restarting the ServiceMix unlocked the port reservation and the ActiveMQ Service restarted without issues.

Note that the previous ActiveMQ process was no running anymore and this seems a limitation of two JVM's and Windows blocking the port as a client still use it. This is not because two instances are trying to start at the same time.

This perhaps does not answer your specific problem, but it can also helps other people having the same setup.

Pang answered 27/2, 2018 at 9:28 Comment(1)
yeah rabbitmq was running in my pc which was what blocking activemq from startingSaarinen
W
1

When we ran into this issue, we found that the default port (61616) is in the "ephemeral port" range (see https://en.wikipedia.org/wiki/Ephemeral_port for a little background). My understanding is that the OS (Windows 2012 in our case) can allocate the port to whatever it wants so long as it's not already in use. For us, it was fine most of the time, but very occasionally when the server booted up, Windows allocated port 61616 to something else before activemq started, so when activemq tried to start, we got this error.

The following excerpt is taken from "http://blogs.technet.com/b/askds/archive/2007/08/24/dynamic-client-ports-in-windows-server-2008-and-windows-vista-or-how-i-learned-to-stop-worrying-and-love-the-iana.aspx" which discusses how to set the ephemeral port range in Windows (this article calls them "dynamic ports"):

In Vista and 2008, most administration of things at the network stack level is handled via NETSH. Using NETSH, it’s possible to see what your dynamic port range is set to on a per server basis:

netsh int ipv4 show dynamicport tcp

netsh int ipv4 show dynamicport udp

netsh int ipv6 show dynamicport tcp

netsh int ipv6 show dynamicport udp

These commands will output the dynamic port range currently in use. Kind of a neat fact is that you can have different ranges for TCP and UDP, or for IPv4 and IPv6, although they all start off the same.

In Windows Server 2003 the range always defaults to starting with TCP port 1024, and that is hard-coded. But in Vista/2008, you can move the starting point of the range around. So if you needed to, you could tell your servers to use ports 5000 through 15000 for dynamic port allocations, or any contiguous range of ports you wanted. To do this, you use NETSH again:

netsh int ipv4 set dynamicport tcp start=10000 num=1000

netsh int ipv4 set dynamicport udp start=10000 num=1000

netsh int ipv6 set dynamicport tcp start=10000 num=1000

netsh int ipv4 set dynamicport udp start=10000 num=1000

The examples above would set your dynamic port range to start at port 10000 and go through port 11000 (1000 ports).

A few important things to know about the port range:

  • The smallest range of ports you can set is 255.

  • The lowest starting port that you can set is 1025.

  • The highest end port (based on the range you set) cannot exceed 65535.

For more information on this, check out KB 929851.

Waxbill answered 13/1, 2016 at 18:57 Comment(1)
Is it possible the port is locked by a client process connecting to the given port because of that? I have that setup and restarting the client (servicemix in my case) make the server (activemq) to be able to start again.Brahman
B
1

I tried all the possible ways mentioned here then

I changed 5672 to 5673 in the below line

<transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>

which is inside this path:

pathToActiveMQ\ActiveMQ\apache-activemq-5.16.0\conf\activemq.xml

finally, it's working after restarting my PC.

May it helps someone.

Brunell answered 20/5, 2021 at 11:42 Comment(0)
H
0

Windows here: Software that communicated with broker had probably hard coded port, so I couldn't change the activemq.xml

I had turned on connection sharing for one of the connections, I've disabled it, and it helped, HUGE thaks to Bin S for this info as netstat didn't show this port as occupied!

Hetman answered 3/1, 2014 at 18:2 Comment(0)
D
0

I run into this issue when deploying an embedded active MQ broker as part of a application based on Apache Camel on a Windows Server 2012R2 host. I followed the advice of posted above and changed the port to which the broker was bound (from 61616 to 6616)

Dodgem answered 7/1, 2016 at 15:58 Comment(0)
A
0

Try running it with admin rights.

In windows- Go to the directory -apache-activemq-5.4.3\bin and Right click on activemq.bat and run as administrator.

Cheers

Afraid answered 11/6, 2017 at 11:39 Comment(0)
K
0

If you are using a java code. Try a check like this.

        if (!brokerService.isStarted()) {
            System.out.println("Bringing up the ActiveMQ Broker");
            brokerService.addConnector("tcp://localhost:61616");
            brokerService.setBrokerName("Broker");
            brokerService.setUseJmx(true);
            brokerService.start();
        } else {
            System.out.println("ActiveMQ Broker already started");
        }
Kellykellyann answered 24/10, 2017 at 3:42 Comment(0)
W
0

The above post are valid that changing openwire port to 6616 work but it might happen to you as happened to me that amqp port was also occupied so u need to change that also(from 5672 to 5762(or any other)) config according to me is:-

  <transportConnector name="openwire" uri="tcp://0.0.0.0:6616?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
        <transportConnector name="amqp" uri="amqp://0.0.0.0:5762?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
        <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
        <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
        <transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
Wayland answered 29/12, 2017 at 9:34 Comment(0)
F
0

ERROR | Failed to start Artemis JMS Message Broker. Reason: Address already in use

In my case i had to make kill the process that was using 8161 in bootstrap.xml (in etc folder)

Following below steps to find PID and kill the process

  1. find the process id that is using this port (in your case, 8161). In command prompt write: netstat -a -o -n and look at the process id.
  2. Next kill the process by typing: taskkill /F /PID "process id" by running the command prompt in administrator mode
Frontward answered 5/3, 2019 at 17:43 Comment(0)
J
0

Sometimes this error is caused when you have Mosquitto installed alongside ActiveMQ. this is a port number conflict caused by Mosquitto MQTT service running on port 1883 whiles Activemq server MQTT feature tries to run on that port. What you have to do is to either edit the mqtt conntector port in the conf/activemq.xml or commenting that line out like this

<!-- <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/> --> 

Then start the service again

Jenellejenesia answered 19/5, 2020 at 9:3 Comment(0)
B
0

Try to make those ports free, if netstat shows you they're free but still it doesn't run just change the ports to 6613 and 6614 in etc/broker.xml. It should help

Boyar answered 17/7, 2020 at 11:17 Comment(0)
F
0

For those who landed on this page through google, pay attention to whether the port in conflict matches your error message.

In this question, the port in conflict is 61616 (Openwire protocol). But if the conflicted port is 5672(AMQP), it might be that there are multiple amqp message brokers installed on the same system.

RabbitMQ and ActiveMQ running on the same machine

Fineberg answered 5/12, 2020 at 1:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.