How to disable mosquitto MQTT local-only mode and listen on all IP addresses

When starting Mosquitto using a default configuration file, you will see log message like

mosquitto_1  | 1637858580: Starting in local only mode. Connections will only be possible from clients running on this machine.

indicating that the mosquitto MQTT broker is only listening on 127.0.0.1 and is not reachable over the network.

In order to fix this, you can simply bind to all IP addresses using

bind_address 0.0.0.0
listener 1883

in mosquitto.conf

Full mosquitto.conf example

persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log

listener 1883
## Authentication ##
allow_anonymous false
password_file /mosquitto/conf/mosquitto.conf

See our previous post on How to setup standalone mosquitto MQTT broker using docker-compose for further details on how to setup a mosquitto MQTT broker using this config.

**If mosquitto is still printing the local only message even though you have listener 1883 in your config file, check if mosquitto is using the correct config file.**In my case, I mis-spelled the config file path (conf instead of config), hence mosquitto used the default config file, not my config file and therefore ignored all statements I put in my config file.