Zigbee2mqtt - Generic Failure and 502: Bad Gateway on web interface

Hello,

I was a “happy customer” of zigbee2mqtt till last week… something happen (maybe an update) and my entire zigbee network started to fail…

Initially I thought that it was a hardware failure, so:

  1. swopped the old TI USB with a new one (Texas_Instruments_TI_CC2531_USB)
  2. purchased a new one ( zig-a-zig-ah! – usb-1a86_USB)

but no luck :frowning:

Then I thought of a SW issue, so I decided to wipe out the Raspberry pi and reinstalling everything from scratch… again no luck :frowning:

Now what I have done after re-installing is the following:

  1. Installed and configure Mosquitto broker add-on (simply added a dedicated user and password and started → no error in log)
  2. Installed ZigBee2MQTT add-on and performed the followings:
  • edited config file as below
mqtt:
  base_topic: zigbee2mqtt
  server: mqtt://localhost:1883
  user: mqttuser
  password: mqttPassword
serial:
  port: /dev/ttyACM0
  • Checked the Log and found the following:
[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... 
[09:39:54] INFO: Socat not enabled, marking service as down
[cont-init.d] socat.sh: exited 0.
[cont-init.d] zigbee2mqtt.sh: executing... 
[09:39:56] INFO: MQTT available, fetching server detail ...
[09:39:57] INFO: Previous config file found, checking backup
[09:39:57] INFO: Creating backup config in '/config/zigbee2mqtt/.configuration.yaml.bk'
[09:39:57] 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.
[09:40:00] INFO: Handing over control to Zigbee2mqtt Core ...
> [email protected] start /app
> node index.js
Zigbee2MQTT:error 2021-06-16 09:40:50: Error while starting zigbee-herdsman
Zigbee2MQTT:error 2021-06-16 09:40:50: Failed to start zigbee
Zigbee2MQTT:error 2021-06-16 09:40:50: Check https://www.zigbee2mqtt.io/information/FAQ.html#help-zigbee2mqtt-fails-to-start for possible solutions
Zigbee2MQTT:error 2021-06-16 09:40:50: Exiting...
Zigbee2MQTT:error 2021-06-16 09:40:50: Error: Failed to connect to the adapter (Error: SRSP - SYS - ping after 6000ms)
    at ZStackAdapter.<anonymous> (/app/node_modules/zigbee-herdsman/dist/adapter/z-stack/adapter/zStackAdapter.js:93:31)
    at Generator.throw (<anonymous>)
    at rejected (/app/node_modules/zigbee-herdsman/dist/adapter/z-stack/adapter/zStackAdapter.js:25:65)
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-06-16T05_41_25_962Z-debug.log
[09:41:26] INFO: Handing over control to Zigbee2mqtt Core ...

And when I try to open ZigBee2MQTT we interface I get 502: Bad Gateway

What am I doing wrong? I saw many people had similar issues in the past, but I could not really find a “unique solution”…

any suggestion would be much appreciated :slight_smile:

Thank you

I just bought a zig-a-zig-ah! myself from having using a CC2531. One thing I notice is that the serial port is different. Try this.

serial:
  port: /dev/ttyUSB0

You can also verify by going to

Supervisor → System → Host system → ⋮ → Hardware

as suggest in the addon doc tab.

thank you for pointing this out… tried, but still same errors :frowning:

[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... 
[10:31:12] INFO: Socat not enabled, marking service as down
[cont-init.d] socat.sh: exited 0.
[cont-init.d] zigbee2mqtt.sh: executing... 
[10:31:14] INFO: MQTT available, fetching server detail ...
[10:31:15] INFO: Previous config file found, checking backup
[10:31:15] INFO: Creating backup config in '/config/zigbee2mqtt/.configuration.yaml.bk'
[10:31:16] 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.
[10:31:18] INFO: Handing over control to Zigbee2mqtt Core ...
> [email protected] start /app
> node index.js
Zigbee2MQTT:error 2021-06-16 10:32:35: Error while starting zigbee-herdsman
Zigbee2MQTT:error 2021-06-16 10:32:35: Failed to start zigbee
Zigbee2MQTT:error 2021-06-16 10:32:35: Check https://www.zigbee2mqtt.io/information/FAQ.html#help-zigbee2mqtt-fails-to-start for possible solutions
Zigbee2MQTT:error 2021-06-16 10:32:35: Exiting...
Zigbee2MQTT:error 2021-06-16 10:32:35: Error: network commissioning timed out - most likely network with the same panId or extendedPanId already exists nearby
    at ZnpAdapterManager.<anonymous> (/app/node_modules/zigbee-herdsman/dist/adapter/z-stack/adapter/manager.js:315:27)
    at Generator.throw (<anonymous>)
    at rejected (/app/node_modules/zigbee-herdsman/dist/adapter/z-stack/adapter/manager.js:25:65)
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-06-16T06_32_35_619Z-debug.log
[10:32:36] INFO: Handing over control to Zigbee2mqtt Core ...

Zigbee2MQTT:error 2021-06-16 10:32:35: Error: network commissioning timed out - most likely network with the same panId or extendedPanId already exists nearby

Change your pan_id. It is still using the same one from CC2531. Try adding another digit from the existing one.

zigbee2mqtt failed to start
Migrating from CC2531

I added a digit to the old pan_id (it was 6754 and now I have set it to 6755) but the log got “worst” :slight_smile:

should I just remove the add-on and restart form scratch?

[services.d] starting services
[services.d] done.
[10:59:28] INFO: Handing over control to Zigbee2mqtt Core ...
> [email protected] start /app
> node index.js
Zigbee2MQTT:error 2021-06-16 10:59:39: Configuration is not consistent with adapter state/backup!
Zigbee2MQTT:error 2021-06-16 10:59:39: - PAN ID: configured=6755, adapter=6754
Zigbee2MQTT:error 2021-06-16 10:59:39: - Extended PAN ID: configured=00124b0022a51dee, adapter=00124b0022a51dee
Zigbee2MQTT:error 2021-06-16 10:59:39: - Network Key: configured=01030507090b0d0f00020406080a0c0d, adapter=01030507090b0d0f00020406080a0c0d
Zigbee2MQTT:error 2021-06-16 10:59:39: - Channel List: configured=11, adapter=11
Zigbee2MQTT:error 2021-06-16 10:59:39: Please update configuration to prevent further issues.
Zigbee2MQTT:error 2021-06-16 10:59:39: If you wish to re-commission your network, please remove coordinator backup at /config/zigbee2mqtt/coordinator_backup.json.
Zigbee2MQTT:error 2021-06-16 10:59:39: Re-commissioning your network will require re-pairing of all devices!
Zigbee2MQTT:error 2021-06-16 10:59:39: Error while starting zigbee-herdsman
Zigbee2MQTT:error 2021-06-16 10:59:39: Failed to start zigbee
Zigbee2MQTT:error 2021-06-16 10:59:39: Check https://www.zigbee2mqtt.io/information/FAQ.html#help-zigbee2mqtt-fails-to-start for possible solutions
Zigbee2MQTT:error 2021-06-16 10:59:39: Exiting...
Zigbee2MQTT:error 2021-06-16 10:59:39: Error: startup failed - configuration-adapter mismatch - see logs above for more information
    at ZnpAdapterManager.<anonymous> (/app/node_modules/zigbee-herdsman/dist/adapter/z-stack/adapter/manager.js:201:35)
    at Generator.next (<anonymous>)
    at fulfilled (/app/node_modules/zigbee-herdsman/dist/adapter/z-stack/adapter/manager.js:24:58)
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-06-16T06_59_39_584Z-debug.log

what is listed here. just so we can confirm it can actually see the new coordinator

some additional info
Zigbee2MQTT won’t start if the coordinator is mapped to ttyUSB0 · Issue #7433 · Koenkk/zigbee2mqtt (github.com)

Upgrading to 1.19 made all devices unjoin · Issue #7665 · Koenkk/zigbee2mqtt (github.com)

both of those issues mention socat in the log

below the “subset of the zigbee antenna”… to me it seems to see it…

  - name: ttyUSB0
    sysfs: >-
      /sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/ttyUSB0/tty/ttyUSB0
    dev_path: /dev/ttyUSB0
    subsystem: tty
    by_id: /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0
    attributes:
      DEVLINKS: >-
        /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0
        /dev/serial/by-path/platform-3f980000.usb-usb-0:1.3:1.0-port0
      DEVNAME: /dev/ttyUSB0
      DEVPATH: >-
        /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3/1-1.3:1.0/ttyUSB0/tty/ttyUSB0
      ID_BUS: usb
      ID_MODEL: USB_Serial
      ID_MODEL_ENC: USB\x20Serial
      ID_MODEL_ID: '7523'
      ID_PATH: platform-3f980000.usb-usb-0:1.3:1.0
      ID_PATH_TAG: platform-3f980000_usb-usb-0_1_3_1_0
      ID_REVISION: '0264'
      ID_SERIAL: 1a86_USB_Serial
      ID_TYPE: generic
      ID_USB_DRIVER: ch341
      ID_USB_INTERFACES: ':ff0102:'
      ID_USB_INTERFACE_NUM: '00'
      ID_VENDOR: 1a86
      ID_VENDOR_ENC: 1a86
      ID_VENDOR_ID: 1a86
      MAJOR: '188'
      MINOR: '0'
      SUBSYSTEM: tty
      TAGS: ':systemd:'
      USEC_INITIALIZED: '37617424758'

do you have this rtscts: false in the zigbee2mqtt config?

advanced:
  log_level: warn
  rtscts: false <------------
  pan_id: 6755
  channel: 11
  network_key:

I’ve read in the how to guide somewhere in this link that states that line should be in the config.

did that, and while it worked for like 30 minutes, then all back to where I start:

[15:08:40] INFO: Handing over control to Zigbee2mqtt Core ...
> [email protected] start /app
> node index.js
Zigbee2MQTT:error 2021-06-16 15:09:09: Error while starting zigbee-herdsman
Zigbee2MQTT:error 2021-06-16 15:09:09: Failed to start zigbee
Zigbee2MQTT:error 2021-06-16 15:09:09: Check https://www.zigbee2mqtt.io/information/FAQ.html#help-zigbee2mqtt-fails-to-start for possible solutions
Zigbee2MQTT:error 2021-06-16 15:09:09: Exiting...
Zigbee2MQTT:error 2021-06-16 15:09:09: Error: Failed to connect to the adapter (Error: SRSP - SYS - ping after 6000ms)
    at ZStackAdapter.<anonymous> (/app/node_modules/zigbee-herdsman/dist/adapter/z-stack/adapter/zStackAdapter.js:93:31)
    at Generator.throw (<anonymous>)
    at rejected (/app/node_modules/zigbee-herdsman/dist/adapter/z-stack/adapter/zStackAdapter.js:25:65)
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-06-16T11_09_09_517Z-debug.log
[15:09:10] INFO: Handing over control to Zigbee2mqtt Core ...
> [email protected] start /app
> node index.js

I have configured duckDNS , but I don’t think that this could make any interference… no?

Sorry, I am out of ideas. This is my config using the same stick.

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
  user: user
  password: user
serial:
  port: /dev/ttyUSB0
advanced:
  log_level: warn
  rtscts: false
  pan_id: 6755
  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=/tmp/ttyZ2M,mode=777
  slave: tcp-listen:8485,keepalive,nodelay,reuseaddr,keepidle=1,keepintvl=1,keepcnt=5
  options: '-d -d'
  log: false

I have the same config… when I restart the raspberry, I need to unplug an plug back the usb dongle…

this make the antenna works (strangely :frowning: )

but I am having trouble to get devices to connect…

any advice?

Did you set to true?


permit_join: true

thank you @duceduc yes it is set to true

loosing hope… my last option is to try on another raspberry :frowning:

Have you looked though the troubleshoot guide?

At this point the coordinator is connecting, but it requires a unplug/plug action every time a restart of the stick?

but I am having trouble to get devices to connect…

Is it not finding any devices at all or it finds it, but having hard time connecting?

Hi FiNaR

I have a similar issue.
Have been using this for months without issues.
Yesterday out of the blue my lights where no longer available.
I use the CC2531 stick.

Config from HA or Zigbee2MQTT had not been changed.

Trying the webinterface gives a 502 bad gateway.

Did you find a solution?

hello @benalla , unfortunately I had to reinstall everything. no fix for me :frowning:

Thanks!
I have ordered the CC2652p now.
So will make a new installation.

Hi @FiNaR

I had the same issue. The solution for me was login into the raspberry through ssh and find the zigbee2mqtt config. For me it was here: /config/zigbee2mqtt/configuration.yaml
I added the mentioned lines:

advanced:
  pan_id: 6755

, and save the config file. I did not restart the addon, just wait for the next cycle when it tries to connect to the usb device, and woala, it worked.

Note: I tried the add theese lines on the addons page before, but that didn’t work form me.

My solution was - to add via ssh

sudo usermod -a -G uucp $USER
sudo usermod -a -G tty $USER
sudo usermod -a -G dialout $USER

Para mi fue esta la solución!! Gracias