Issue Getting simple MQTT working

I have home assistant installed on a ubuntu headless server. I have a raspberry pi with mosquitto installed on it. I want to be able to send MQTT messages from the PI to the server.

  • Home Assistant Ubuntu Servier IP: 192.168.1.12

  • Mosquitto Raspberry Pi IP: 192.168.1.172

Configuration in Home Assistant

mqtt:
  broker: 192.168.1.172
  port: 1883
  client_id: home-assistant
  protocol: 3.1

sensor:
  - platform: mqtt
    name: "Test MQTT"
    state_topic: "home-assistant/test/value"

Command from PI

mosquitto_pub -h 192.168.1.12 -t "home-assistant/test/value" -m "10"
Error: Connection refused

For some reason I just can’t get home assistant to actually accept the messages from the PI.

Figured it out, the pi needs to publish to the broker on the pi itself and home assistant is subscribed to it. So for those who might be in the same boat I had to change the mosquitto_pub to publish to itself (change the ip in my case to .172, could have probably done 127.0.0.1 or localhost too).