Zigbee2MQTT - Web UI not opening - 502 Bad Gateway

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)

@milutm did you find the solution, i have exact same issue. All logs seem fine, just error in system log when trying to get to ui.

Hi. Yes i find solition for this.
U have to delete all files connected with zigbee (mqtt broker and zigbee2mqtt addons) before it uninstall boty addons and restart HA. Then delete. Restart HA. Install addons config and it should work.

Just done that with no difference. :frowning:

Well, we are the 1st of February today. Version 1.22.3 (or maybe 1.23.0) should arrive today. Maybe you will have more luck with that one.

Edit: it is 1.23

I had this same issue, I ended up disabling ZHA which was accessing the same Zigbee dongle. In the past I could run them both, but now seems to be an access issue. Once I disabled ZHA, reloaded Z2M and it worked fine.

I finally solved it.
mqtt was the issue.
I used to have:

server: 192.168.0.50:1883

The solution was:

server: mqtt://192.168.0.50
2 Likes

It’s a miracle. After probably 10’s of hours of reading up on this problem, implementing pretty much everybody’s suggestions, It think waving a dead cat over my head in the cemetery at midnight was ultimately what solved the problem for me.

I know the “scientific method” is to change one thing at a time and observe the results - and that’s good advice a lot of the time, but at some point you’ll try anything. Two different approaches to installing zigbee2mqtl resulted in configuration folders in both /config and /config/custom_components; ultimately the install that worked was Configuration/Add-ons/Zigbee2mqtt versus a direct Github-based install.

I did have one self-caused problem: by virtue of changing to an USB-based SSD, the device my zigbee coordinator was plugged into changed. ls -l /dev/serial/by-id in terminal provided the needed port info.

Anyway, here’s the configuration that ultimately worked. For those having the same problem (there are a LOT of us) - good luck.

data_path: /config/zigbee2mqtt
external_converters: []
devices: devices.yaml
groups: groups.yaml
homeassistant: true
permit_join: true
mqtt:
  base_topic: zigbee2mqtt
serial:
  port: /dev/ttyUSB0
advanced:
  log_level: warn
  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

so simple - Solved everything

Still have this issue and i can’t find any way to solve it.
{
“external_converters”: ,
“devices”: [
“devices.yaml”
],
“groups”: [
“groups.yaml”
],
“homeassistant”: true,
“permit_join”: false,
“mqtt”: {
“base_topic”: “zigbee2mqtt”,
“server”: “mqtt://core-mosquitto”,
“user”: “addons”,
“password”: “ta9iec1theechohZiz2ui3lah7Uahaebah0gahtholuqu0eef8Sho9kaejaim9ae”
},
“serial”: {
“port”: “/dev/serial/by-id/usb-dresden_elektronik_ingenieurtechnik_GmbH_ConBee_II_DE2476068-if00”,
“adapter”: “deconz”
},
“advanced”: {
“log_level”: “warn”,
“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
}

Also in the z2mqtt all seems to be good.
[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…
[15:03:22] INFO: Socat not enabled, marking service as down
[cont-init.d] socat.sh: exited 0.
[cont-init.d] zigbee2mqtt.sh: executing…
[15:03:23] INFO: MQTT available, fetching server detail …
[15:03:23] INFO: MQTT credentials not configured, trying to auto-discovering …
[15:03:24] INFO: Configuring’addons’ mqtt user
[15:03:24] INFO: Previous config file found, checking backup
[15:03:24] INFO: Creating backup config in ‘/config/zigbee2mqtt/.configuration.yaml.bk’
[15:03:24] 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.
[15:03:25] INFO: Handing over control to Zigbee2mqtt Core …

[email protected] start
node index.js
CREATED DECONZ ADAPTER