Mosquitto add-on: Connection refused

Hello, I’m using Hassio 0.87.1 with official Mosquitto add-on which I configured with this guide. So I left default config settings (without username and password), created a new user and then used the user’s credentials in MQTT integrations. My broker is the IP of my Pi that is running Hassio and port is 1883 with discovery enabled. I have no mqtt: in configuration.yaml as the guide advised.

When I restarted the Home Assistant, info doesn’t show any error logs and system even shows success login from the user. But when I run following commands in SSH as a test, I get Connection refused: not authorised.

Can you help me what am I doing wrong?

Here are my system logs: https://paste.ubuntu.com/p/RfYxf3qYjg/
And here are Mosquitto add-on logs: https://paste.ubuntu.com/p/knvZPCT3cD/

It has been a while since I set this up but I think this is wrong. See step 6 here:

Also what have you got in the log on the mosquitto addon page?

So I should leave it blank and set port and broker? I chose MQTT integration from all available integrations. If I choose the MQTT integration at top of the page I can only enable discovery, nothing else.

I added add.on logs in the reply.

As I said, it has been a while but I think this is what you need to do.

Mosquitto log?

You can leave out everything in config yaml and use the integration with discovery and leave the broker at the defaults (as long as you use a HA username/password for your devices) It will all just work.

I set it up as you advised and still get the same error in SSH. This is my log right now: https://paste.ubuntu.com/p/Jw49jvmj7J/

So I should put mqtt: in configuration.yaml as well? If so, what should i put there?

Put NOTHING in there.

What is your username? You can’t use homeassistant as the username…

One other thing, after you add or remove an integration (not an addon) you need to restart home assistant!!

I haven’t set any username in config for add-ons and integration didn’t offer me any option to insert username or password.

Yes, I restart every time.

You don’t need to specify a username and password if you use a home assistant user for your devices when you configure MQTT (on the device). I also use the default settings for the addon…

The only caveat as I said is your Home assistant user cannot be homeassistant and I think addons is the other reserved name.

I have been running like this for 6 months.

I don’t follow. So basically I don’t need to do anything but specify on the client device username and password? And ti should be one of the home assistant users as long as it’s not homeassistant and addons?

That is correct.

Okay, is there any way to test if it works?

Use a client like mqttfx to publish something to the mqtt broker, check the mosquitto addon log for successful connection.

You can do the same thing from the Home Assistant developer tools MQTT page.

I’m not at my local network (accessing HA remotely), so I guess it won’t work now, right?

You can still do this:

I probably don’t know how to do it. I’m trying to publish /homeassistant/hello topic with “Hello” in payload and nothing shows in the logs. Not even unsuccessful connection.

I’m getting these messages right now after I restarted add-on: Disconnected from MQTT (1). Trying to reconnect in 16 s.