Ecowitt2Mqtt on Mosquitto and Docker

I am trying to get Ecowitt@MQTT running on my Docker Mosquitto container. I have gotten as far as receiving a message from the Ecowitt gateway, GW3000, however when the message is passed on to Mosquitto I receive error 2, name not recognized. I have a Python Paho client running for testing and it communicates correctly with Mosquitto. I have tired several configurations for Ecowitt2MQTT the only one that worked partially was with --Nework=Bridge, using port 8085:8085 for conncting to the gateway and 1883 for the Ecowitt2mqtt to Mosquitto.
The Docker Run command for Ecowitt2mqtt:

β€œβ€"

docker run -itd --name e2mqtt --net=bridge -p 8085:8085 -e ECOWITT2MQTT_MQTT_BROKER=192.168.1.122 -e ECOWITT2MQTT_MQTT_BROKER=mosquitto -e ECOWITT2MQTT_MQTT_PORT=1883 -e MQTT_USERNAME=XXXXXX -e MQTT_PASSWORD=XXXXXXX -e ECOWITT2MQTT_HASS_DISCOVERY=false -e ECOWITT2MQTT_PORT=8085 -e input-data-format=ecowitt -e ECOWITT2MQTT_DIAGNOSTICS=true bachya/ecowitt2mqtt:latest

β€œβ€"

The mosquitto.conf file:

β€œβ€"

#listener 1883 socket_domain ipv4
allow_anonymous false
listener 1883 0.0.0.0 socket_domain ipv4
persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log
password_file /mosquitto/config/password_file

β€œβ€"

System Info:

β€œβ€"

Ubuntu 24.04 32 GB memory
Everything is installed on this computer

Client: Docker Engine - Community
Version: 29.2.1
API version: 1.53

Mosquitto version 2.1.2

Ecowitt2mqtt (version 2026.01.0)

β€œβ€"

Any suggestions are greatly appreciated. I’ve been working with this for several days now. I am fairly new to Docker and brand new to Mosquitto.

1 Like

Please tell me what was wrong with this post that it was 'Hidden" THX

Hello,

I believe this might be related to networking problems. by default two container wonΒ΄t be able to communicate with each other.

In your command above you are using also two endpoints which should overwrite each other.

Try:
docker exec e2mqtt ping -c 3 mosquitto

If this does not work, this means container mosquitto can not be reached from your e2mqtt container.

You can solve this e.g. by setting up both container in a docker network, which allows them to use service names for communication.

Thanks for your reply. I had already started on your suggestion after doing some more studying of docker. Now I’m getting a validation error from the compose.yaml file.
β€œβ€"

1 validation error for Config

Value error, must provide at least one of: mqtt_topic, hass_discovery [type=value_error, input_value={}, input_type=dict]

β€œβ€"

I have tried several things to clear it but no luck. Yaml File

β€œβ€"

name: run
services:
ecowitt2mqtt:
container_name: e2mqtt
environment:
ECOWITT2MQTT_HASS_DISCOVERY:{FALSE: null}
ECOWITT2MQTT_INPUT_DATA_FORMAT:ecowitt: null
ECOWITT2MQTT_MQTT_BROKER:mosquitto: null
ECOWITT2MQTT_MQTT_PASSWORD:gw3000: null
ECOWITT2MQTT_MQTT_PORT:1883: null
ECOWITT2MQTT_MQTT_TOPIC:{sensors/gw3000: null}
ECOWITT2MQTT_MQTT_USERNAME:ecowitt: null
ECOWITT2MQTT_PORT:8085: null
image: bachya/ecowitt2mqtt:latest
networks:
mqtt-net: null
ports:

  • mode: ingress
    target: 8080
    published: β€œ8085”
    protocol: tcp
    restart: unless-stopped
    mosquitto:
    container_name: mosquitto
    image: eclipse-mosquitto:latest
    networks:
    mqtt-net: null
    ports:
  • mode: ingress
    target: 1883
    published: β€œ1883”
    protocol: tcp
    restart: unless-stopped
    volumes:
  • type: bind
    source: /opt/mosquitto/config
    target: /mosquitto/config
    bind: {}
  • type: bind
    source: /opt/mosquitto/data
    target: /mosquitto/data
    bind: {}
  • type: bind
    source: /opt/mosquitto/log
    target: /mosquitto/log
    bind: {}
    networks:
    mqtt-net:
    name: run_mqtt-net
    driver: bridge

β€œβ€"

I appreciate your help on this.

It looks like you’ve run into the β€œYAML spacing trap.” The validation error must provide at least one of: mqtt_topic, hass_discovery is happening because Docker Compose isn’t actually reading your environment variables correctly.

I am not 100% sure, as the way you have pasted it it is not really readable.
But please check the formatting details.

can you try this? :

services:
e2mqtt:
image: bachya/ecowitt2mqtt:latest
container_name: e2mqtt
restart: unless-stopped
networks:

  • mqtt-net
    ports:
  • β€œ8085:8085”
    environment:
  • ECOWITT2MQTT_MQTT_BROKER=mosquitto
  • ECOWITT2MQTT_MQTT_PORT=1883
  • ECOWITT2MQTT_MQTT_USERNAME=ecowitt
  • ECOWITT2MQTT_MQTT_PASSWORD=gw3000
  • ECOWITT2MQTT_MQTT_TOPIC=sensors/gw3000
  • ECOWITT2MQTT_INPUT_DATA_FORMAT=ecowitt
  • ECOWITT2MQTT_PORT=8085
  • ECOWITT2MQTT_HASS_DISCOVERY=false

mosquitto:
image: eclipse-mosquitto:latest
container_name: mosquitto
restart: unless-stopped
networks:

  • mqtt-net
    ports:
  • β€œ1883:1883”
    volumes:
  • /opt/mosquitto/config:/mosquitto/config
  • /opt/mosquitto/data:/mosquitto/data
  • /opt/mosquitto/log:/mosquitto/log

networks:
mqtt-net:
driver: bridge

When I pasted it into my editor everything is left justified. I’ll make it look like your’s and let you know. Can I substitute β€˜-’ for the bullet points?

It took a while to get it all correct but I finally got it to run. Now both Mosquitto and ecowitt2mqtt are running in their own docker containers. I just don’t see any activity from e2mqtt. I have turned on verbose and diagnostics and except for the opening info nothing shows up. Using wireshark I can see a message go to port 8085 with but nothing ever shows up on my client side. Mosquitto is working, I can send and receive messages to it correctly. I would like to get e2mqtt working because I understand the data and format are easier to work with.

Thanks for your help

You can check the logs of Mosquitto to understand if ou are connected. Turning on log_type all even adds more information. You would be able to identify your client based on the clientid and see if the connection and publishes work.

Depending on your setup, it could be an authorization problem. Maybe e2mqtt is not allowed to publish to the topic it trys to publish.