Zigbee2MQTT - Web UI not opening - 502 Bad Gateway

Hi there,
I have just installed Zigbee2MQTT. When you look at the logs, everything seems to work just fine. But the Web UI does not open. It just shows 502: Bad Gateway.

Here is the log from Zigbee2MQTT:

2021-01-19T09:29:53: PM2 log: App [npm:0] starting in -fork mode-
2021-01-19T09:29:53: PM2 log: App [npm:0] online
> [email protected] start /zigbee2mqtt-1.17.0
> node index.js
Zigbee2MQTT:info  2021-01-19 09:29:57: Logging to console and directory: '/share/zigbee2mqtt/log/2021-01-19.09-29-56' filename: log.txt
Zigbee2MQTT:info  2021-01-19 09:29:57: Starting Zigbee2MQTT version 1.17.0 (commit #1.17.0)
Zigbee2MQTT:info  2021-01-19 09:29:57: Starting zigbee-herdsman (0.13.46)
Zigbee2MQTT:info  2021-01-19 09:30:00: zigbee-herdsman started
Zigbee2MQTT:info  2021-01-19 09:30:00: Coordinator firmware version: '{"meta":{"maintrel":3,"majorrel":2,"minorrel":6,"product":0,"revision":20190608,"transportrev":2},"type":"zStack12"}'
Zigbee2MQTT:info  2021-01-19 09:30:00: Currently 0 devices are joined:
Zigbee2MQTT:warn  2021-01-19 09:30:00: `permit_join` set to  `true` in configuration.yaml.
Zigbee2MQTT:warn  2021-01-19 09:30:00: Allowing new devices to join.
Zigbee2MQTT:warn  2021-01-19 09:30:00: Set `permit_join` to `false` once you joined all devices.
Zigbee2MQTT:info  2021-01-19 09:30:00: Zigbee: allowing new devices to join.
Zigbee2MQTT:info  2021-01-19 09:30:00: Started frontend on port 0.0.0.0:1883
Zigbee2MQTT:info  2021-01-19 09:30:00: Connecting to MQTT server at mqtt://192.168.178.22:1883
Zigbee2MQTT:info  2021-01-19 09:30:00: Connected to MQTT server
Zigbee2MQTT:info  2021-01-19 09:30:01: MQTT publish: topic 'zigbee2mqtt/bridge/state', payload 'online'
Zigbee2MQTT:info  2021-01-19 09:30:01: MQTT publish: topic 'zigbee2mqtt/bridge/info', payload '{"commit":"1.17.0","config":{"advanced":{"adapter_concurrent":null,"adapter_delay":null,"availability_blacklist":[],"availability_blocklist":[],"availability_passlist":[],"availability_timeout":0,"availability_whitelist":[],"cache_state":true,"cache_state_persistent":true,"cache_state_send_on_startup":true,"channel":11,"elapsed":false,"ext_pan_id":[221,221,221,221,221,221,221,221],"homeassistant_discovery_topic":"homeassistant","homeassistant_legacy_triggers":true,"homeassistant_status_topic":"hass/status","last_seen":"disable","legacy_api":true,"log_directory":"/share/zigbee2mqtt/log/%TIMESTAMP%","log_file":"log.txt","log_level":"info","log_output":["console","file"],"log_rotation":true,"log_syslog":{},"pan_id":6754,"report":false,"soft_reset_timeout":0,"timestamp_format":"YYYY-MM-DD HH:mm:ss"},"ban":[],"blocklist":[],"device_options":{},"devices":{},"experimental":{"new_api":true,"output":"json"},"external_converters":[],"frontend":{"port":1883},"groups":{},"homeassistant":true,"map_options":{"graphviz":{"colors":{"fill"

Here is my Zigbee2MQTT Config:

data_path: /share/zigbee2mqtt
external_converters: []
devices: devices.yaml
groups: groups.yaml
homeassistant: true
permit_join: true
mqtt:
  base_topic: zigbee2mqtt
  server: 'mqtt://192.168.178.22:1883'
  user: mos-broker
  password: (MY PASSWORD)
serial:
  port: >-
    /dev/serial/by-id/usb-Texas_Instruments_TI_CC2531_USB_CDC___0X00124B0018E27BA3-if00
advanced:
  log_level: info
  pan_id: 6754
  channel: 11
  network_key:
    - 1
    - 3
    - 5
    - 7
    - 9
    - 11
    - 13
    - 15
    - 0
    - 2
    - 4
    - 6
    - 8
    - 10
    - 12
    - 13
  availability_blocklist: []
  availability_passlist: []
device_options: {}
blocklist: []
passlist: []
queue: {}
frontend:
  port: 1883
experimental:
  new_api: true
socat:
  enabled: false
  master: 'pty,raw,echo=0,link=/dev/ttyZ2M,mode=777'
  slave: 'tcp-listen:8485,keepalive,nodelay,reuseaddr,keepidle=1,keepintvl=1,keepcnt=5'
  restartdelay: 1
  initialdelay: 1
  options: '-d -d'
  log: false

You are using the MQTT port 1883 for the web-frontend of Z2M as well. Are both running on the same machine?

I think so. I have installed both the Mosquitto Broker and HA on my Rasberry Pi 4.

Both using port 1883 will not work. Besides, 1883 is the MQTT port, you should not use it for something else.

Change Z2Mā€™s frontend to another port

frontend:
  port: 8080

to open it at http://192.168.178.22:8080/

1 Like

Thanks for your reply. I have changed Z2Mā€™s port to 8080, but the Web UI still is not working and I canā€™t access http://192.168.178.22:8080/.

Iā€™m currently using http://192.168.178.22:8123/ to open my HA, does that make any difference?

If I change

mqtt:
  base_topic: zigbee2mqtt
  server: 'mqtt://192.168.178.22:1883'

to

mqtt:
  base_topic: zigbee2mqtt
  server: 'mqtt://192.168.178.22:8080'

Z2M wonā€™t connect to MQTT at all (so say the logs).

No, because you want to open the WebUI of Zigbee2MQTT, not the one of Home Assistant.

  • did you restart Zigbee2MQTT after changing the configuration?
  • do you use Docker of another container / virtualization platform that requires extra steps to expose ports?
  • does sudo netstat -tlnp show an open port 8080 on IP 0.0.0.0?
  • did you restart Zigbee2MQTT after changing the configuration?
    Yes.

  • do you use Docker of another container / virtualization platform that requires extra steps to expose ports?
    No.

  • does sudo netstat -tlnp show an open port 8080 on IP 0.0.0.0?
    Yes.

Mensch, da fehlen ein paar Basics, oder?

  • mqtt://192.168.178.22:1883 is the URL that Zigbee2MQTT uses to connect to your Mosquitto broker (Mosquitto listens on port 1883). Infact you could even discard the port number as 1883 is the default
  • http://192.168.178.22:8080 is the URL that you type in your browser to connect to the frontend of Zigbee2MQTT. It cannot be port 1833, as this port on the target IP is used by Mosquitto.

When calling the netstat-command, what program is named in the last column (ā€œPID/Program nameā€), maybe port 8080 is also blocked by another program? Firewall active?

I am also getting the same problem. same set up as you, its only just began happening though today.

Using Zigbee2MQTT version 1.17.0-dev (commit #d1a1035) with frontend on port 8080, I can access and use the Web UI on Zigbee2MQTT. I do not have a firewall in use.

I also do not use a firewall or any program that could block port 8080.

Zigbee2MQTT:error 2021-01-19 14:51:53: Error while starting zigbee-herdsman
Zigbee2MQTT:error 2021-01-19 14:51:53: Failed to start zigbee
Zigbee2MQTT:error 2021-01-19 14:51:53: Exitingā€¦
Zigbee2MQTT:error 2021-01-19 14:51:53: Error: Failed to connect to the adapter (Error: SRSP - SYS - ping after 6000ms)

Thatā€™s some different log than mine. I think you have something wrong with you Z2M config because it ā€œfailed to start Zigbeeā€. My Z2M starts as normal just the WEB UI does not work.

So i stopped addon, pulled out the usb stick, waited 10 seconds, put it back in and started addon againā€¦ working?!

Yesterday, after updated my Portainer (with HomeBridge) from node js 14.15.0 to 14.15.4 and npm version to 6.14.10) I got the also a 502: Bad Gateway

I changed nothing in my HA. No changes in the configuration oe anything else. The error I get:

READ THIS CAREFULLY
Refusing to start because configuration is not valid, found the following errors:
- friendly_name shoud atleast be 1 char long
If you don't know how to solve this, read https://www.zigbee2mqtt.io/information/configuration.html
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
npm
 ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR!
 [email protected] start: `node index.js`
npm ERR! Exit status 1
npm ERR! 
npm 
ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2021-02-02T07_39_38_916Z-debug.log
2021-02-02T08:39:39: PM2 log: App [npm:0] exited with code [1] via signal [SIGINT]
2021-02-02T08:39:39: PM2 log: App [npm:0] starting in -fork mode-
2021-02-02T08:39:39: PM2 log: App [npm:0] online
> [email protected] start /zigbee2mqtt-1.17.1
> node index.js

The error tells me to the configuration which I did not changed. Also ā€˜- friendly_nameā€™ is not mentioned in my configuration of Zigbee2mqtt

my configuration:

data_path: /share/zigbee2mqtt
external_converters: []
devices: devices.yaml
groups: groups.yaml
homeassistant: true
permit_join: false
mqtt:
  base_topic: zigbee2mqtt
  server: 'mqtt://core-mosquitto:1883'
  user: mqtt
  password: ****
serial:
  port: /dev/ttyACM0
advanced:
  log_level: info
  pan_id: 6754
  channel: 11
  network_key:
    - 1
    - 3
    - 5
    - 7
    - 9
    - 11
    - 13
    - 15
    - 0
    - 2
    - 4
    - 6
    - 8
    - 10
    - 12
    - 13
  availability_blocklist: []
  availability_passlist: []
device_options: {}
blocklist: []
passlist: []
queue: {}
frontend:
  port: 8099
experimental: {}
socat:
  enabled: false
  master: 'pty,raw,echo=0,link=/dev/ttyZ2M,mode=777'
  slave: 'tcp-listen:8485,keepalive,nodelay,reuseaddr,keepidle=1,keepintvl=1,keepcnt=5'
  restartdelay: 1
  initialdelay: 1
  options: '-d -d'
  log: false

I had this exact error when updating to latest zigbee2mqtt integration.

Rolled back to a previous snapshot and all okay again.

friendly_name shoud atleast be 1 char long issue here tooā€¦

For now I rolled back to previous z2m version trough a snapshotā€¦

Does anyone has a solution yet?
Or maybe we have to wait till thereā€™s a patch in version 1.17.2

Hello! I
had exactly the same error, and restoring the last copy with the previous version also helped. Four hours lost. :slightly_smiling_face: