# Client is not authorized to connect

**URL:** <https://community.hivemq.com/t/client-is-not-authorized-to-connect/856>\
**Category:** HiveMQ Cloud\
**Created:** [December 3, 2021, 5:32am UTC](https://community.hivemq.com/t/client-is-not-authorized-to-connect/856 "2021-12-03T05:32:17Z")\
**Posts on this page:** 8\
**Page:** 3

<div class="post-metadata">

**Author:** ![chaiyasitr](https://avatars.discourse-cdn.com/v4/letter/c/9fc29f/32.png) [@chaiyasitr](https://community.hivemq.com/u/chaiyasitr)\
**Post date:** [April 7, 2022, 1:28am UTC](https://community.hivemq.com/t/client-is-not-authorized-to-connect/856/41 "2022-04-07T01:28:28Z")

</div>

@DKrueger @Daria_H  
Any more suggestion for our issue ? Did you have a chance to have a look at the listeners ?

Regards,

---

<div class="post-metadata">

**Author:** ![arctrus](https://avatars.discourse-cdn.com/v4/letter/a/c89c15/32.png) [@arctrus](https://community.hivemq.com/u/arctrus)\
**Post date:** [July 2, 2022, 5:40pm UTC](https://community.hivemq.com/t/client-is-not-authorized-to-connect/856/42 "2022-07-02T17:40:27Z")

</div>

I am trying to connect a device from Iotify simulator (web address:iotify.io) to hivemq broker.

when I am using public address and mqtt protocol every thing is ok, but when I am trying to connecting device to MQTT cloud broker for free service and mqtt over TLS, client side says not authorized!

I was searching and reading topics for 2 days but problem not solving still!

Also I want to deploy my local hivemq but after installing, the service of hivemq restart repeatedly each one second!

Please Guide me!

---

<div class="post-metadata">

**Author:** ![Daria\_H](https://avatars.discourse-cdn.com/v4/letter/d/dfb087/32.png) [@Daria\_H](https://community.hivemq.com/u/Daria_H)\
**Post date:** [August 4, 2022, 10:07am UTC](https://community.hivemq.com/t/client-is-not-authorized-to-connect/856/43 "2022-08-04T10:07:51Z")

</div>

Hi @arctrus ,

Thanks for sharing this. Your local deployment might fail due to insufficient resources:

> [@arctrus](#):
>
> Also I want to deploy my local hivemq but after installing, the service of hivemq restart repeatedly each one second!

Does your hardware meet [Minimum Hardware Requirements](https://www.hivemq.com/docs/hivemq/4.8/user-guide/system-requirements.html#minimum)?

For connecting to the HiveMQ Cloud broker you need to enable TLS, specify port 8883, supply Username and Password. Your client should have the TLS extension _Server Name Indication_ (SNI) enabled. Please refer to [this post](https://community.hivemq.com/t/ewon-flexy-device-not-able-to-connect-to-hive-mq-mqtt-broker/1183/11) that explains how to check this.

I hope this helps,  
Dasha from HiveMQ team

---

<div class="post-metadata">

**Author:** ![bakis](https://avatars.discourse-cdn.com/v4/letter/b/ecc23a/32.png) [@bakis](https://community.hivemq.com/u/bakis)\
**Post date:** [November 23, 2022, 3:28pm UTC](https://community.hivemq.com/t/client-is-not-authorized-to-connect/856/44 "2022-11-23T15:28:10Z")

</div>

Any update on this issue? I am facing the same issue. other brokers works, ffree hive MQ works, but HiveMQ Cluster with username not works…

in the discussion is encoding and encryption mentioned. **Any reference how HiveMQ CLuster is implemented?**

The issue is not in TLS

The issue is on MQTT level during connection.

Mosquitto, Azure, AWS works.

---

<div class="post-metadata">

**Author:** ![bwjohns4](https://avatars.discourse-cdn.com/v4/letter/b/838e76/32.png) [@bwjohns4](https://community.hivemq.com/u/bwjohns4)\
**Post date:** [November 25, 2022, 6:14pm UTC](https://community.hivemq.com/t/client-is-not-authorized-to-connect/856/45 "2022-11-25T18:14:15Z")

</div>

I am also having this issue. I’m using BG95 and this is quite frustrating…

---

<div class="post-metadata">

**Author:** ![bwjohns4](https://avatars.discourse-cdn.com/v4/letter/b/838e76/32.png) [@bwjohns4](https://community.hivemq.com/u/bwjohns4)\
**Post date:** [November 30, 2022, 4:52pm UTC](https://community.hivemq.com/t/client-is-not-authorized-to-connect/856/46 "2022-11-30T16:52:22Z")

</div>

I found the resolution to be enabling SNI on the BG95 by doing:  
AT+QSSLCFG=“SNI”,“Your SSL Context ID”,1 for example:  
AT+QSSLCFG=“SNI”,1,1 worked for me

Here’s what SNI is for reference: [https://www.cloudflare.com/learning/ssl/what-is-sni/](https://www.cloudflare.com/learning/ssl/what-is-sni/)

---

<div class="post-metadata">

**Author:** ![noob](https://avatars.discourse-cdn.com/v4/letter/n/5e9695/32.png) [@noob](https://community.hivemq.com/u/noob)\
**Post date:** [January 27, 2023, 3:38pm UTC](https://community.hivemq.com/t/client-is-not-authorized-to-connect/856/47 "2023-01-27T15:38:31Z")

</div>

I was having the same symptoms as @chaiyasitr and it was @simon_b who solved this in my case.

To confirm symptoms I had:  
TLS Ver1.2 with SNI enabled handshake succeeded.  
But CONNECT resulted in CONNACK return value of 5: CONN\_REFUSED\_NOT\_AUTHORIZED

Analyzed wireshark logs as advised in this thread  
and inside the TLS Client Hello: server name was being sent (by my client code incorrectly) as an IP address rather than the required server name as shown in the screenshot by simon\_b above.

So I changed my client code to use the correct server name rather than the IP address and I now get:  
CONNACK return value of 0: “Connection Accepted”

Thank you for the comment that helped me resolve this Simon!

---

<div class="post-metadata">

**Author:** ![plbertrand](https://avatars.discourse-cdn.com/v4/letter/p/c37758/32.png) [@plbertrand](https://community.hivemq.com/u/plbertrand)\
**Post date:** [June 30, 2023, 7:01pm UTC](https://community.hivemq.com/t/client-is-not-authorized-to-connect/856/48 "2023-06-30T19:01:14Z")

</div>

That’s what did it for me:

```auto
def wrap_socket(self, sock, *args, **kwargs):
    kwargs['server_hostname'] = self._server_hostname
    return super().wrap_socket(sock, *args, **kwargs)

```

Passing `server_hostname` as \*\*ssl\_params on `ssl.wrap_socket()`.

[Previous page](https://community.hivemq.com/t/client-is-not-authorized-to-connect/856.md?page=2)
