# Getting "Connection Refused: not authorised" when trying to use MQTT

**URL:** <https://www.thethingsnetwork.org/forum/t/getting-connection-refused-not-authorised-when-trying-to-use-mqtt/9863>\
**Category:** Application Development\
**Created:** [October 3, 2017, 3:40pm UTC](https://www.thethingsnetwork.org/forum/t/getting-connection-refused-not-authorised-when-trying-to-use-mqtt/9863 "2017-10-03T15:40:07Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![gandipg](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/g/ecd19e/32.png) [@gandipg](https://www.thethingsnetwork.org/forum/u/gandipg)\
**Post date:** [October 3, 2017, 3:40pm UTC](https://www.thethingsnetwork.org/forum/t/getting-connection-refused-not-authorised-when-trying-to-use-mqtt/9863/1 "2017-10-03T15:40:07Z")

</div>

Hello  
can you help me with configuring MQTT

because what I find in your site  
still gives me a mistake

---

<div class="post-metadata">

**Author:** ![BoRRoZ](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/borroz/32/44234_2.png) [@BoRRoZ](https://www.thethingsnetwork.org/forum/u/BoRRoZ)\
**Post date:** [October 3, 2017, 3:40pm UTC](https://www.thethingsnetwork.org/forum/t/getting-connection-refused-not-authorised-when-trying-to-use-mqtt/9863/2 "2017-10-03T15:40:59Z")

</div>

that’s not enough[info](https://status.thethings.network/) 😉

---

<div class="post-metadata">

**Author:** ![gandipg](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/g/ecd19e/32.png) [@gandipg](https://www.thethingsnetwork.org/forum/u/gandipg)\
**Post date:** [October 3, 2017, 3:45pm UTC](https://www.thethingsnetwork.org/forum/t/getting-connection-refused-not-authorised-when-trying-to-use-mqtt/9863/3 "2017-10-03T15:45:52Z")

</div>

by starting this

`$mosquitto_sub -h eu.thethings.network -d -t '.../devices/../up'`

he wrote this to me

–Connection Refused: not authorised.

I am recording and a pass a user  
still gives me this

---

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [October 3, 2017, 4:58pm UTC](https://www.thethingsnetwork.org/forum/t/getting-connection-refused-not-authorised-when-trying-to-use-mqtt/9863/4 "2017-10-03T16:58:12Z")

</div>

> [@gandipg](#):
>
> pass a user

Your command line doesn’t show that. What are you using as the user, and what as the password? (So: show us that you’ve in fact read the documentation and tell us which documentation you’re using, rather than expecting people to list all possible problems.)

As an aside, `'.../devices/.../up'` is wrong too.

---

<div class="post-metadata">

**Author:** ![nicbkw](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/nicbkw/32/44893_2.png) [@nicbkw](https://www.thethingsnetwork.org/forum/u/nicbkw)\
**Post date:** [October 3, 2017, 4:59pm UTC](https://www.thethingsnetwork.org/forum/t/getting-connection-refused-not-authorised-when-trying-to-use-mqtt/9863/5 "2017-10-03T16:59:05Z")

</div>

You need to provide an access token, similar to this:

`mosquitto_sub -h eu.thethings.network -t '+/devices/+/events/activations' -u 'APP-ID' -P 'ACCESS-KEY' -v -p 1883`

APP-ID is the actual name of your application.  
ACCESS-KEY can be retrieved from the Overview page of your application (at the bottom)

---

<div class="post-metadata">

**Author:** ![gandipg](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/g/ecd19e/32.png) [@gandipg](https://www.thethingsnetwork.org/forum/u/gandipg)\
**Post date:** [October 3, 2017, 6:09pm UTC](https://www.thethingsnetwork.org/forum/t/getting-connection-refused-not-authorised-when-trying-to-use-mqtt/9863/6 "2017-10-03T18:09:31Z")

</div>

in this option I write it  
`mosquitto_sub -h eu.thethings.network -t '+/devices/+/events/activations' -u '70...................81' -P 'AB.......................E3' -v -p 1883`

and yet it gives me a mistake  
Connection Refused: not authorised.  
Connection Refused: not authorised.

---

<div class="post-metadata">

**Author:** ![gandipg](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/g/ecd19e/32.png) [@gandipg](https://www.thethingsnetwork.org/forum/u/gandipg)\
**Post date:** [October 3, 2017, 6:19pm UTC](https://www.thethingsnetwork.org/forum/t/getting-connection-refused-not-authorised-when-trying-to-use-mqtt/9863/7 "2017-10-03T18:19:42Z")

</div>

I use this documentation from my site  
[https://www.thethingsnetwork.org/docs/applications/mqtt/quick-start.html](https://www.thethingsnetwork.org/docs/applications/mqtt/quick-start.html)

---

<div class="post-metadata">

**Author:** ![kersing](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/kersing/32/44777_2.png) [@kersing](https://www.thethingsnetwork.org/forum/u/kersing)\
**Post date:** [October 3, 2017, 7:40pm UTC](https://www.thethingsnetwork.org/forum/t/getting-connection-refused-not-authorised-when-trying-to-use-mqtt/9863/8 "2017-10-03T19:40:54Z")

</div>

> [@gandipg](#):
>
> `-u '70…81' -P 'AB…E3'`

Read the manual again.

> [@](#):
>
> `-u "< AppID >" -P "< AppKey >"`

AppID == Application ID, that should be a short ‘name’, listed at the top of all information on the **application** page. It is **not** an EUI number.  
AppKey should start with ttn-account-.

---

<div class="post-metadata">

**Author:** ![nicbkw](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/nicbkw/32/44893_2.png) [@nicbkw](https://www.thethingsnetwork.org/forum/u/nicbkw)\
**Post date:** [October 3, 2017, 7:42pm UTC](https://www.thethingsnetwork.org/forum/t/getting-connection-refused-not-authorised-when-trying-to-use-mqtt/9863/9 "2017-10-03T19:42:05Z")

</div>

I think you are using appeui not the actual application name as your user. Also, check you are using the access key, starting with ttn-account

---

<div class="post-metadata">

**Author:** ![gandipg](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/g/ecd19e/32.png) [@gandipg](https://www.thethingsnetwork.org/forum/u/gandipg)\
**Post date:** [October 3, 2017, 8:03pm UTC](https://www.thethingsnetwork.org/forum/t/getting-connection-refused-not-authorised-when-trying-to-use-mqtt/9863/10 "2017-10-03T20:03:03Z")

</div>

thank you all  
it finally came about  
he has been stirring all the time  
`-u "<AppID>" -P "<AppKey>"`  
🍻

---

<div class="post-metadata">

**Author:** ![pramodmynampati](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/p/94ad74/32.png) [@pramodmynampati](https://www.thethingsnetwork.org/forum/u/pramodmynampati)\
**Post date:** [March 9, 2018, 6:03pm UTC](https://www.thethingsnetwork.org/forum/t/getting-connection-refused-not-authorised-when-trying-to-use-mqtt/9863/11 "2018-03-09T18:03:11Z")

</div>

Hello all,

I started playing with the Things Network recently.

I have successfully connected my device to the TTN and am able to see the packets being received by the TTN server on its application console.

However when trying to use MQTT (through mosquitto) on my laptop I am facing the same problem which @gandipg suffered.

On my laptop

I am entering the following cmd as mentioned in the Quick start tutorial

`mosquitto_sub -h ev.thethings.network -t '+/devices/+/up' -u '2222' -P '...16 byte...' -v`

I am getting Connection Refused: not authorised.

Now Mr @nicbkw mentioned that the access key starts with ttn-account.

On my application console my access-key doesn’t seem to start with that anywhere.

Any clues as to where I am going wrong.

Your help would be appreciated.

Kind Regards

---

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [March 9, 2018, 6:12pm UTC](https://www.thethingsnetwork.org/forum/t/getting-connection-refused-not-authorised-when-trying-to-use-mqtt/9863/12 "2018-03-09T18:12:25Z")

</div>

> [@pramodmynampati](#):
>
> ev.thethings.network

That doesn’t look right. What region would `ev` be?

> [@pramodmynampati](#):
>
> On my application console my access-key doesn’t seem to start with that anywhere.

I just created a new application, and it still creates keys with that prefix. Maybe you can add a new key (for at least “messages”) to fix that? If not, create a new application?

 ![image](https://www.thethingsnetwork.org/forum/uploads/default/original/2X/2/2974a0cf18860c14d631a7af7231c7249939378d.jpg)

Also, it’s a lot longer than 16 bytes, for me it’s 58 characters.

---

<div class="post-metadata">

**Author:** ![nicbkw](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/nicbkw/32/44893_2.png) [@nicbkw](https://www.thethingsnetwork.org/forum/u/nicbkw)\
**Post date:** [March 9, 2018, 6:45pm UTC](https://www.thethingsnetwork.org/forum/t/getting-connection-refused-not-authorised-when-trying-to-use-mqtt/9863/13 "2018-03-09T18:45:16Z")

</div>

Quick response as I am in the pub…  
If your application is called ‘2222’, then in the console open the overview for the application and it should look similar to this, just copy the key using the icon:

![Screenshot_20180309-183712](https://www.thethingsnetwork.org/forum/uploads/default/original/2X/1/1d8f8c735733da736a8c7dee8de0ce0e78a5666f.png)

---

<div class="post-metadata">

**Author:** ![pramodmynampati](https://www.thethingsnetwork.org/forum/letter_avatar_proxy/v4/letter/p/94ad74/32.png) [@pramodmynampati](https://www.thethingsnetwork.org/forum/u/pramodmynampati)\
**Post date:** [March 10, 2018, 3:36pm UTC](https://www.thethingsnetwork.org/forum/t/getting-connection-refused-not-authorised-when-trying-to-use-mqtt/9863/14 "2018-03-10T15:36:26Z")

</div>

Thank you both for your quick response.

@nicbkw - thank you for suggestion for looking at the overview of the console. That resolved the issue.  
My mistake was to be entering the App Session Key for the device I registered.

@arjanvanb - ‘ev’ is a typo on my part when writing the question on this forum. I was using ‘eu’ as the region.

Regards

---

<div class="post-metadata">

**Author:** ![bl00dy](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/bl00dy/32/36752_2.png) [@bl00dy](https://www.thethingsnetwork.org/forum/u/bl00dy)\
**Post date:** [June 5, 2020, 7:39am UTC](https://www.thethingsnetwork.org/forum/t/getting-connection-refused-not-authorised-when-trying-to-use-mqtt/9863/15 "2020-06-05T07:39:45Z")

</div>

Hello,

when I try to connect with MQTT, getting “Connection Refused: not authorised.” but it was worked before. I am sure I use correct applikation Key, even I try to create new.

mosquitto\_sub -h eu.thethings.network -t ‘+/devices/+/events/activations’ -u ‘70B3D57ESKIPPED’ -P ‘ttn-account-v2.skipped’ -v

---

<div class="post-metadata">

**Author:** ![kersing](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/kersing/32/44777_2.png) [@kersing](https://www.thethingsnetwork.org/forum/u/kersing)\
**Post date:** [June 5, 2020, 8:14am UTC](https://www.thethingsnetwork.org/forum/t/getting-connection-refused-not-authorised-when-trying-to-use-mqtt/9863/16 "2020-06-05T08:14:47Z")

</div>

For the user you need to use the application ID (short text string).

---

<div class="post-metadata">

**Author:** ![bl00dy](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/bl00dy/32/36752_2.png) [@bl00dy](https://www.thethingsnetwork.org/forum/u/bl00dy)\
**Post date:** [June 5, 2020, 8:22am UTC](https://www.thethingsnetwork.org/forum/t/getting-connection-refused-not-authorised-when-trying-to-use-mqtt/9863/17 "2020-06-05T08:22:58Z")

</div>

Hello,

Yes. I use EUIS

Ed

---

<div class="post-metadata">

**Author:** ![bl00dy](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/bl00dy/32/36752_2.png) [@bl00dy](https://www.thethingsnetwork.org/forum/u/bl00dy)\
**Post date:** [June 5, 2020, 8:29am UTC](https://www.thethingsnetwork.org/forum/t/getting-connection-refused-not-authorised-when-trying-to-use-mqtt/9863/18 "2020-06-05T08:29:50Z")

</div>

Ok. thanks seems it’s working now with application ID.

but I remember it’s worked before with EUIS
