1

I am new to RabbitMQ and I am trying out the simple example in Nodejs.

const amqp    = require('amqplib/callback_api');
amqp.connect('amqp://guest:guest@localhost:15672',function(err, 
conn) {
    console.log("Enter in callback",conn);
    if (err) {
      console.error("[AMQP]", err.message);
      return err;
    }
    conn.on("error", function(err) {
      if (err.message !== "Connection closing") {
        console.error("[AMQP] conn error", err.message);
      }
    });
    conn.on("close", function() {
      console.error("[AMQP] reconnecting");
      return;
    });

    console.log("[AMQP] connected");
    amqpConn = conn;
    callback(null,"Success");
  });

I am seeing 'conn error connect ECONNREFUSED 127.0.0.1:15672' error. Please let me know where I am doing wrong and I can access it from web using http://localhost:15672.

Thanks

Ankit Uniyal
  • 424
  • 1
  • 7
  • 20

2 Answers2

1

The RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.


15672 is the HTTP API port. You should connect to port 5672, which is the default AMQP TCP port.

Please note that the documentation on rabbitmq.com is very comprehensive and worth reading carefully. The network troubleshooting document could have assisted you in figuring this out.

Luke Bakken
  • 8,993
  • 2
  • 20
  • 33
  • Thanks its working now. I am using AWS SAM local which runs inside docker, so I should be using my system IP address instead of localhost when connecting to RabbitMQ. – Ankit Uniyal Jun 27 '18 at 06:42
0

Just switching from

amqp://guest:guest@localhost:5672

to

amqp://127.0.0.1:5672 worked for me.

Dipesh Lohani
  • 306
  • 3
  • 11