"Connection refused: server unavailable" error while connecting Arduino MKRGSM with Azure IoT Hub

Sahithya 1 Reputation point

I am registering my Arduino MKRGSM board with Azure Iot Hub by following this link:


Arduino MKRGSM 1400 device is successfully registered in the IoT Hub. but, when I am trying to connect the MKRGSM board to IoT Hub with the example provided in the arduino IDE,
Arduino IDE using File -> Examples -> Arduino Cloud Provider Examples -> AzureIoTHub-> Azure_IoT_Hub_GSM

In the serial monitor, I could see that, the board is getting connected to cellular network successfully, but whenever it is attempting to connect with MQTT, I am getting an error 3(Connection refused:Server unavailable) from the mqttClient.connect(broker, 8883). what would be the reason for this error?
But after few hours(around 10 hours) of registering the device in IoT Hub, i could able to communicate with the device without any error.

why it is taking time to connect with IoT Hub? can anyone suggest me to get through this. Thanks.

Azure IoT
Azure IoT
A category of Azure services for internet of things devices.
385 questions
Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,136 questions
{count} votes

1 answer

Sort by: Most helpful
  1. QuantumCache 20,106 Reputation points

    Hello all,

    As a troubleshooting step in this scenario, we recommend using a new Azure IoTHub created and connect another real IoT Device example using the: IoT Plug and Play app quickly.https://play.google.com/store/apps/details?id=com.iot_pnp&hl=en_IN&gl=US

    and connect to the IoT hub. Then send the telemetry messages. It can be monitored using IoT explorer Install and use Azure IoT explorer | Microsoft Learn

    Please comment in the below section if you also face the same issue. Happy to help!

    1 person found this answer helpful.
    0 comments No comments