MQTT Server Issue - Connection Refused not authorized

I had the same issue, for me it was because I had not updated the location of the password file in the mqtt config, Check step 5 in the SD build. If you are installing manually I recommend reviewing the SD image build instructions. There are a few steps here that I think are missing on the other build instructions.

Turn off Mosquitto persistence and enable authentication:

sudo nano /etc/mosquitto/mosquitto.conf
Set persistence false and add the lines:

allow_anonymous false
password_file /etc/mosquitto/passwd

Create a password file for MQTT user emonpi with:

sudo mosquitto_passwd -c /etc/mosquitto/passwd emonpi
Enter password emonpimqtt2016 (default)

Test MQTT

Open another shell window to subscribe to a test topic:

mosquitto_sub -v -u ‘emonpi’ -P ‘emonpimqtt2016’ -t ‘test/topic’
Publish to the test topic :

mosquitto_pub -u ‘emonpi’ -P ‘emonpimqtt2016’ -t ‘test/topic’ -m ‘helloWorld’

SD Build