Reputation: 11512
I'm running a stock RabbitMQ install on MacOS. Start the server up fine with just 'rabbitmq-server'.
Using the Java API I can easily connect to RabbitMQ with "localhost" as the host like this:
val factory = new ConnectionFactory()
factory.setHost( "localhost" )
val connection = factory.newConnection()
However, when I try a different IP (e.g. the actual IP of my machine) I get a connection refused error.
Exception in thread "main" java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at com.rabbitmq.client.impl.FrameHandlerFactory.create(FrameHandlerFactory.java:32)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:615)
at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:639)
at com.gwz.Junk$delayedInit$body.apply(Junk.scala:8)
at scala.Function0$class.apply$mcV$sp(Function0.scala:40)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:12)
at scala.App$$anonfun$main$1.apply(App.scala:71)
at scala.App$$anonfun$main$1.apply(App.scala:71)
at scala.collection.immutable.List.foreach(List.scala:318)
at scala.collection.generic.TraversableForwarder$class.foreach(TraversableForwarder.scala:32)
at scala.App$class.main(App.scala:71)
at com.gwz.Junk$.main(Junk.scala:5)
at com.gwz.Junk.main(Junk.scala)
My ifconfig shows inet addresses like these:
inet 127.0.0.1 netmask 0xff000000
inet 172.16.240.21 netmask 0xffffff00 broadcast 172.16.240.255
inet 192.168.59.3 netmask 0xffffff00 broadcast 192.168.59.255
inet 10.0.0.125 netmask 0xffffff00 broadcast 10.0.0.255
The loopback 127.0.0.1 works. The others, however, don't. I need one of the other 3 to work.
Do I need to do something else to allow connection by my local IP?
Upvotes: 0
Views: 8750
Reputation: 11512
There may be more than one solution, but what I found was this:
First open up loopback_users in rabbitmq.conf:
[{rabbit, [{loopback_users, []}]}].
Then I put my local machine's IP address in rabbitmq-env.conf (wherever its installed on your machine):
NODE_IP_ADDRESS=10.0.1.45
This defaulted to localhost for me, so these two changes together allowed my guest account to be accessed with a non-localhost IP.
Upvotes: 1