"mosquitto_sub" with Connection Refused: not authorised

Hi Brocaar

Thanks for the all works you had done, everything seems worked well

but I can’t use mosquitto_sub command to do something. e.g. send and receive data.

I tried this commands:

mosquitto_sub -v -t “application/+/node/+/+” -u loraroot -P {mypassword} -h localhost -p 1883
mosquitto_sub -v -t “application/+/node/+/+”

all shown:Connection Refused: not authorised.

I had just some basic setting follow Quick Install, I didn’t setup the ACL file

Alao I have follow questions:
what is “Application ID”? Where can I find that? Application name is the ID?

Somehow Mosquitto sees the client ID generated by mosquitto_sub as suspicious. Use the -i flag to specify a random client id. If that doesn’t work.

If you didn’t setup any ACL files, then you can omit the -u and -P flags :slight_smile:

 mosquitto_sub -v -t "application/#" -i 654321

Like this?

Still show Connection Refused: not authorised.

Could you share your mosquitto.conf or whatever file you are using as configuration?

Yes of course, I was frogot that:

Place your local configuration in /etc/mosquitto/conf.d/

A full description of the configuration file is at


pid_file /var/run/mosquitto.pid

persistence true
persistence_location /var/lib/mosquitto/

log_dest file /var/log/mosquitto/mosquitto.log

include_dir /etc/mosquitto/conf.d

Please copy contents of any relevant file in /etc/mosquitto/conf.d too.

Just a local.conf and readme file in conf,d

Here is the local.conf:

allow_anonymous false
password_file /etc/mosquitto/pwd

Maybe your passwords are not correctly set. When passwords are given and anonymous access is not allowed, either a wrong user/pass combination or no user/pass given will fail. Regarding this, here’s a summary table taken from http://www.steves-internet-guide.com/mqtt-username-password-example/:

Anonymous access Password file Specified Access Restricted
True No No
True Yes Yes See Note 1
False No Yes -see Note 2
False Yes Yes

Note1: If a password file is specified then if the client sends a username/password then it must be valid other wise an authentication error is returned. If it doesn’t send one then none is required and a normal connection results.

Note 2: The client must send a Username and password, but it is not checked. If the client doesn’t send a username/password then and authentication error code is generated.

With some test, I don’t think my passwords are not correctly set.

If with a wrong passwords configration, how could lora server and lora app server run?

Shown in Quick Install guide, there are 4 users(loraroot, loragw, loraserver, loraappserver), witch one should I user for data recive and send?

And can you show me you set up steps for mosquitto?

Thank you iegomez

I fixed that problem, indeed I still don’t know how did I fixed that:sweat_smile:

but the data recived is encrypted, how can I decrypt it?

I’m glad you worked it out. The data received is already decrypted but base64 encoded. Just decode it (using a script, an online base64 encoder/decoder, etc.) to get the original bytes sent by the device. Also, check this for information about sending and receiving data: https://docs.loraserver.io/lora-app-server/integrate/data/.

Hello @hunter8801. Could you please give the steps,that you followed and finally solved this issue?

1 Like


Can you try some thing like this?

mosquitto_sub -v -t “application/#” -u loraroot -P yourpassword


in my local machine server i used to do like this!

mosquitto_sub -v -t “application/#” -u loraroot -P yourpassword -h -p 1883


1 Like

Problem solved, with the below command.

Thanks @Praveen_Kumar_R!

Welcome :slight_smile: