dockerdocker-composemqttmosquitto

Docker mosquitto Adress not available


I try to build a docker-compose for mosquitto and node red, but no matter what i do, i always get the same error from mosquitto. mosq | 1716134494: Error: Address not available

i even tried to minimize the configurations in the compose file to

version: '3.8'

services:
  mosquitto:
    image: eclipse-mosquitto:latest
    container_name: mosq
    ports:
      - 1883:1883

and still int wont work. I checked to exit all my other containers, even if none of them use the same port.


Solution

  • You need to add this to your mosquitto.conf

    listener 1883
    

    Details can be found here https://mosquitto.org/documentation/migrating-to-2-0/

    version: '3.8'
    
    services:
      mosquitto:
        image: eclipse-mosquitto:latest
        container_name: mosq
        ports:
          - 1883:1883
        volumes:
          - ./mosquitto.conf:/mosquitto/config/mosquitto.conf
    

    You will see something like this

    mosq  | mosquitto version 2.0.18 starting
    mosq  | Config loaded from /mosquitto/config/mosquitto.conf.
    mosq  | Opening ipv4 listen socket on port 1883.
    mosq  | Opening ipv6 listen socket on port 1883.
    mosq  | mosquitto version 2.0.18 running
    
    

    and port will be open on 1883 for more configuration options I suggest you to check https://github.com/eclipse/mosquitto/blob/master/mosquitto.conf