Emoncms cannot connect to mqtt server

I installed Emoncms on a VPS using the Debian install script. The following error is shown in the log
2021-12-10 09:30:48.038|ERROR|emoncms_mqtt.php|unexpected connection problem mqtt server:Connection Refused: not authorised.
I used all the default usernames and passwords as the system installed. Any suggestions please?

From the terminal I do this
sudo mosquitto_sub -v -u ‘emonpi’ -P ‘emonpimqtt2016’ -t ‘emon/#’
It sits and waits so I assume that it connected

Then with this
sudo mosquitto_sub -v -u ‘emoncms’ -P ‘emoncmsmqtt2016’ -t ‘emon/#’
Connection Refused: not authorised.

Hello @mariusl I assume mosquitto is running ok?

This is the script that installs mosquitto and sets mosquitto.conf, might be worth checking that these steps applied ok…

I used the script that is supplied for Debian installation. I think Mosquitto is running fine but I will go through the steps that you suggested.

This is the terminal on the VPS?
Is the log error is generated by that first mosquitto_sub command? Or the second _sub?

If it’s the second, then it’s probably correct.

The first line sitting and waiting it correct, it’s waiting for some incoming messages.
If you log in to a second terminal (or use screen), then publish some data to mosquitto, it should show up in the first command.

I ended up re-installing the system. Maybe it was not required but I needed to know that I did everything correct.
I do not know why the emoncms connection with the mqtt server failed as I used the automated install script. After the reinstall that problem went away.
Then I think there might be some confusion on my part with regards to topic definitions.
On the emonesp I defined the topic to be emon/# and the same on emoncms. This failed. Then looking at the debug output from the emonesp I saw another piece that was required.
I changed the topic to emon/emonesp/# and that seemed to work.
I also managed to connect emoncms with emonesp by using the device API-KEY.
I am now connecting to the VPS using emonesp