Error: connect ECONNREFUSED

I have deployed a NodeJS server that communicates with HiveMQ public broker to Bluehost but I have faced this error.

My config code:

var options = {
  host: process.env.MQTT_PUBLIC_BROKER,
  username: process.env.MQTT_USERNAME,
  password: process.env.MQTT_PASSWORD,
  cleanSession: true,
  keepAlive: 60,
  protocol: "mqtt",
  port: process.env.MQTT_PORT,
};

var client = mqtt.connect(options);

host: “broker.hivemq.com”,
port: 1883

Thank you.

Hi svayio,

And welcome to our community! You did not ask anything in your ticket, but I guess you are asking for help to “fix” the error?

  1. First you need to test if your code works with alternative MQTT Broker. For example, test.mosquitto.org:1883. Let us know, if you see the error and if it is the same error.
  2. Next, please let us know, which MQTT Client library your NodeJS-thing is using. Or where is documentation for the library? If you are following somebodies article or how-to, please share the original link with us.

Thank you,
Dasha from HiveMQ