Zigbee2MQTT - Web UI not opening - 502 Bad Gateway

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:

Open groups.yaml in file editor and see if you have a random blank entry in there as that’s what I had. No idea how as never use zigbee groups but this is what caused the issue.

1 Like

Yes, for me that was the solution:
To erase everything inside groups.yaml

Hello! I had exactly the same error. Use CC2531 and now green LED all the time switch from “on” to “off” after 3-5 sec. after restarting the system. Before - it was all the time “on”.

Zigbee2MQTT:info Starting zigbee-herdsman (0.13.59)
Zigbee2MQTT: Error while starting zigbee-herdsman
Zigbee2MQTT: Failed to start zigbee
Zigbee2MQTT: Exiting…
Zigbee2MQTT: Error: Failed to connect to the adapter (Error: SRSP - SYS - ping after 6000ms)

hello,
i do not know if anyone monitor this thread but i am facing the same issue.
New install.
here is my log .

[13:12:57] INFO: Handing over control to Zigbee2mqtt Core ...
> [email protected] start /app
> node index.js
Zigbee2MQTT:error 2021-05-04 13:13:01: Error while starting zigbee-herdsman
Zigbee2MQTT:error 2021-05-04 13:13:01: Failed to start zigbee
Zigbee2MQTT:error 2021-05-04 13:13:01: Check https://www.zigbee2mqtt.io/information/FAQ.html#help-zigbee2mqtt-fails-to-start for possible solutions
Zigbee2MQTT:error 2021-05-04 13:13:01: Exiting...
Zigbee2MQTT:error 2021-05-04 13:13:01: Error: Error while opening serialport 'Error: Error: No such file or directory, cannot open /dev/ttyACM0'
    at Znp.<anonymous> (/app/node_modules/zigbee-herdsman/dist/adapter/z-stack/znp/znp.js:136:32)
    at Generator.next (<anonymous>)
    at /app/node_modules/zigbee-herdsman/dist/adapter/z-stack/znp/znp.js:27:71
    at new Promise (<anonymous>)
    at __awaiter (/app/node_modules/zigbee-herdsman/dist/adapter/z-stack/znp/znp.js:23:12)
    at SerialPort.<anonymous> (/app/node_modules/zigbee-herdsman/dist/adapter/z-stack/znp/znp.js:134:49)
    at SerialPort._error (/app/node_modules/zigbee-herdsman/node_modules/@serialport/stream/lib/index.js:198:14)
    at /app/node_modules/zigbee-herdsman/node_modules/@serialport/stream/lib/index.js:242:12
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-05-04T10_13_01_822Z-debug.log

Any thoughts?
thanks all!

Hi Guys,
The same issue here:
502: Bad Gateway
Socket error on client , disconnecting.

Can anyone assist, please? I’m completely new to HA, and any support is very welcome.

Many thanks in advance.

MQTT version: 6.0.1
Core Version: core-2021.10.6

MQTT config:
logins: []
customize:
active: false
folder: mosquitto
certfile: fullchain.pem
keyfile: privkey.pem
require_certificate: false

1883 Normal MQTT
1884 MQTT over WebSocket
8883 Normal MQTT with SSL
8884 MQTT over WebSocket with SSL

Integration is made using “homeassistant” default configuration (homeassistant user name and generated password).

I also have the same problem. I made several, fresh installations.
Add-ons: deCONZ, SSH, TextEditor and Zigbee2mqtt (also tried the Edge-variant).

I had it up and running for a short while, but suddenly - bad gateway - and I haven’t been able to get it up and running, since.

21-11-20 20:09:07 INFO (SyncWorker_5) [supervisor.docker.addon] Starting Docker add-on homeassistant/aarch64-addon-deconz with version 6.10.0
21-11-20 20:09:11 ERROR (MainThread) [supervisor.api.ingress] Ingress error: Cannot connect to host 172.30.33.3:8099 ssl:default [Connect call failed ('172.30.33.3', 8099)]
21-11-20 20:09:30 INFO (MainThread) [supervisor.homeassistant.api] Updated Home Assistant API token
21-11-20 20:09:34 ERROR (MainThread) [supervisor.api.ingress] Ingress error: Cannot connect to host 172.30.33.2:8099 ssl:default [Connect call failed ('172.30.33.2', 8099)]
21-11-20 20:09:36 ERROR (MainThread) [supervisor.api.ingress] Ingress error: Cannot connect to host 172.30.33.2:8099 ssl:default [Connect call failed ('172.30.33.2', 8099)]

Unless you have 2 Zigbee sticks, that will never work. It is either deCONZ or Zigbee2mqtt, only one can use your stick at the same time.

1 Like

I must have misunderstood something quite basic - now it works!!!
Much appreciated.

I was a bit too quick - the problem is back. I made a fresh, updated installation, installed and configured Zigbee2mqtt and hooked up three sensors. Everything was looking fine and dandy… until it wasn’t.
I tried removing Zigbee2mqtt and tried the Edge-version… same thing: 502 Bad Gateway-error.

Zigbee2mqtt Edge is the only installed plugin. The log returns the same errors as earlier:

21-11-21 22:10:45 WARNING (MainThread) [supervisor.misc.tasks] Watchdog found a problem with 45df7312_zigbee2mqtt_edge!
21-11-21 22:10:45 INFO (SyncWorker_0) [supervisor.docker.interface] Cleaning addon_45df7312_zigbee2mqtt_edge application
21-11-21 22:10:52 INFO (SyncWorker_0) [supervisor.docker.addon] Starting Docker add-on zigbee2mqtt/zigbee2mqtt-edge-armv7 with version edge
21-11-21 22:10:54 INFO (SyncWorker_1) [supervisor.docker.interface] Stopping addon_45df7312_zigbee2mqtt_edge application
21-11-21 22:10:56 INFO (SyncWorker_1) [supervisor.docker.interface] Cleaning addon_45df7312_zigbee2mqtt_edge application
21-11-21 22:11:05 INFO (SyncWorker_1) [supervisor.docker.addon] Starting Docker add-on zigbee2mqtt/zigbee2mqtt-edge-armv7 with version edge
21-11-21 22:11:20 ERROR (MainThread) [supervisor.api.ingress] Ingress error: Cannot connect to host 172.30.33.0:8099 ssl:default [Connect call failed ('172.30.33.0', 8099)]
21-11-21 22:12:09 INFO (SyncWorker_3) [supervisor.docker.interface] Stopping addon_45df7312_zigbee2mqtt_edge application
21-11-21 22:12:12 INFO (SyncWorker_3) [supervisor.docker.interface] Cleaning addon_45df7312_zigbee2mqtt_edge application
21-11-21 22:12:15 INFO (SyncWorker_3) [supervisor.docker.addon] Starting Docker add-on zigbee2mqtt/zigbee2mqtt-edge-armv7 with version edge
21-11-21 22:12:39 INFO (SyncWorker_1) [supervisor.docker.interface] Stopping addon_45df7312_zigbee2mqtt_edge application
21-11-21 22:12:43 INFO (SyncWorker_1) [supervisor.docker.interface] Cleaning addon_45df7312_zigbee2mqtt_edge application
21-11-21 22:12:49 INFO (SyncWorker_2) [supervisor.docker.addon] Starting Docker add-on zigbee2mqtt/zigbee2mqtt-edge-armv7 with version edge
21-11-21 22:12:59 ERROR (MainThread) [supervisor.api.ingress] Ingress error: Cannot connect to host 172.30.33.0:8099 ssl:default [Connect call failed ('172.30.33.0', 8099)]
21-11-21 22:13:10 ERROR (MainThread) [supervisor.api.ingress] Ingress error: Cannot connect to host 172.30.33.0:8099 ssl:default [Connect call failed ('172.30.33.0', 8099)]
21-11-21 22:13:14 ERROR (MainThread) [supervisor.api.ingress] Ingress error: Cannot connect to host 172.30.33.0:8099 ssl:default [Connect call failed ('172.30.33.0', 8099)]
21-11-21 22:13:51 ERROR (MainThread) [supervisor.api.ingress] Ingress error: Cannot connect to host 172.30.33.0:8099 ssl:default [Connect call failed ('172.30.33.0', 8099)]

My configuration:

data_path: /config/zigbee2mqtt
external_converters: []
devices: devices.yaml
groups: groups.yaml
homeassistant: true
permit_join: false
mqtt:
  base_topic: zigbee2mqtt
  server: mqtt://40.69.xxx.xxx <- (My mosquitto-installation)
  user: mqtt
  password: thisismypassword
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: {}
availability: false
socat:
  enabled: false
  master: pty,raw,echo=0,link=/tmp/ttyZ2M,mode=777
  slave: tcp-listen:8485,keepalive,nodelay,reuseaddr,keepidle=1,keepintvl=1,keepcnt=5
  options: '-d -d'
  log: false

UPDATE: Seems a faulty MQTT-server caused the issue. When restarted, the debug-window was flooded with readings and immediately after, the Home Assistant log went all green.

same problem here. how can i solve it?
zigbee2mqtt config:

data_path: /config/zigbee2mqtt
external_converters: []
devices: devices.yaml
groups: groups.yaml
homeassistant: true
permit_join: false
mqtt:
  base_topic: zigbee2mqtt
serial:
  port: tcp://192.168.5.122:8888
  adapter: ezsp
advanced:
  log_level: debug
  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: {}
availability: false
socat:
  enabled: false
  master: pty,raw,echo=0,link=/tmp/ttyZ2M,mode=777
  slave: tcp-listen:8485,keepalive,nodelay,reuseaddr,keepidle=1,keepintvl=1,keepcnt=5
  options: '-d -d'
  log: false

zigbee2mqtt log:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] socat.sh: executing... 
[07:08:02] INFO: Socat not enabled, marking service as down
[cont-init.d] socat.sh: exited 0.
[cont-init.d] zigbee2mqtt.sh: executing... 
[07:08:03] INFO: MQTT available, fetching server detail ...
[07:08:03] INFO: MQTT server settings not configured, trying to auto-discovering ...
[07:08:03] INFO: Configuring 'mqtt://core-mosquitto:1883' mqtt server
[07:08:04] INFO: MQTT credentials not configured, trying to auto-discovering ...
[07:08:04] INFO: Configuring'addons' mqtt user
[07:08:04] INFO: Previous config file found, checking backup
[07:08:04] INFO: Creating backup config in '/config/zigbee2mqtt/.configuration.yaml.bk'
[07:08:04] INFO: Adjusting Zigbee2mqtt core yaml config with add-on quirks ...
[cont-init.d] zigbee2mqtt.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[07:08:05] INFO: Handing over control to Zigbee2mqtt Core ...
> [email protected] start
> node index.js
Zigbee2MQTT:debug 2021-11-29 07:08:12: Loaded state from file /config/zigbee2mqtt/state.json
Zigbee2MQTT:info  2021-11-29 07:08:12: Logging to console and directory: '/config/zigbee2mqtt/log/2021-11-29.07-08-09' filename: log.txt
Zigbee2MQTT:debug 2021-11-29 07:08:13: Removing old log directory '/config/zigbee2mqtt/log/2021-11-29.05-43-50'
Zigbee2MQTT:info  2021-11-29 07:08:13: Starting Zigbee2MQTT version 1.22.0-dev (commit #82f5ddb)
Zigbee2MQTT:info  2021-11-29 07:08:13: Starting zigbee-herdsman (0.13.174)
Zigbee2MQTT:debug 2021-11-29 07:08:13: Using zigbee-herdsman with settings: '{"adapter":{"concurrent":null,"delay":null,"disableLED":false},"backupPath":"/config/zigbee2mqtt/coordinator_backup.json","databaseBackupPath":"/config/zigbee2mqtt/database.db.backup","databasePath":"/config/zigbee2mqtt/database.db","network":{"channelList":[11],"extendedPanID":[221,221,221,221,221,221,221,221],"networkKey":"HIDDEN","panID":6754},"serialPort":{"adapter":"ezsp","path":"tcp://192.168.5.122:8888"}}'

and supervisor log:

21-11-29 07:57:11 ERROR (MainThread) [supervisor.api.ingress] Ingress error: Cannot connect to host 172.30.33.3:8099 ssl:default [Connect call failed ('172.30.33.3', 8099)]

All on rpi4b mosquitto broker and zigbee2mqtt as supervisor addons.
I using adguard home and remote ui (nabu casa)