Zigbee2MQTT - Web UI not opening - 502 Bad Gateway

I had the same issue. It was so difficult for me. This is what I done to solve it:

1 Uninstall mosquito and zigbee2mqtt. Reboot home assistant.

2 Plug the coordinator to the raspberry and flash it with commands following the steps on this video

3 Disconnect the coordinator and conect it again

4 Reconfigure the zigbee2mqtt and mosquito addons, following the steps on this other video

And thats all done. Hope this help

Do not reboot or shut down home assistant until you added at least one zigbee device.

None of the above helped me to get passed the 502 gateway error.
I had to delete the lines user: and password in the mqtt: section of the configuration, restart at the prompt and bang, working properly straight after.
Perhaps there is no one-size-fits-all solution.

1 Like

After trying all the options I had read, enable, enable and configure plugins. My solution has been very easy.
Zigbee2mqtt version 1.24.0-1, the only port to work for me is:
Interface:
port: 8099

Any other port I put in returns Bad gateway if I start the UI.
putting the port 8099 that appears in the documentation is the only one that has worked for me. If I change it, it stops working.

1 Like

@wassman
Thanks for sharing your solution!
That fix the Bad Gateway fo me to!
I had tried a buch of random port but It needed 8099!
:beers:

Thank you very much. Port 8099 solved my problem with bad gateway, too

I GOT IT!!! After hours. Here is my configuration of the addon:
data_path: /config/zigbee2mqtt
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
mqtt:
server: mqtt://core-mosquitto
user: mymqttusername
password: mymqttuserpassword
serial:
port: /dev/ttyUSB0
frontend:
port: 8099

Mine worked instantly after updating deconz conbee2 firmwareā€¦

Thanks for the idea. it is working for me.

This worked for me, thanks! - with a few changes:

1 no change
2 My USB came flashed - so I skipped this step
3 I skipped this step
4 I followed the video from here: Setting up Zigbee2MQTT and MQTT broker Mosquito in Home Assistant - YouTube and added the following lines to the zigbee2mqtt configuration:

mqtt:
server: mqtt://core-mosquitto:1883
user: mqtt
password: IS369i
serial:
port: /dev/ttyACM0

How to find the correct values?

http://homeassistant.local:8123/hassio/system then ā€œHostā€ 3-dots ā€œHardwareā€
Search for your device. I bought a Texas Instruments CC2531-based USB dongle, so I entered ā€œTexasā€ (or ā€œ2531ā€) and found the serial port.

Create the user.

did you have to repair all your devices after doing this ?

No, not needed

I had to erase all due to an error, and I had to start again. I realized one thing. Now if you configure the add-on itā€™s a bit different.

Leave like it is by default:
*data_path

*Socat

*In mqtt you need to add this:

server: mqtt://core-mosquitto
user: your mqtt user name
password: your mqtt user password

*In the serial you need to add the port:
port: /dev/ttyUSB1

(you can find them in home assistant settings, system, hardware and search for your stick name, should be at the end, and you need to find the ttyUSB and the number, could be ACM0, ttyUSB0, ttyUSB1ā€¦)

AFTER THIS, go to the add-on, before start the addon, click on show in lateral bar, and start the addon. The most probably is you have the bad gateway error. Click on the lateral bar, several times at least you donā€™t see the error. Nothing special more to do, you need to reload the addon at least it loads correctly.

If you see the page without the bad gateway error you need to link one device at least for not loose the right load of the addon. Or you will need to reload the addon several times again.

1 Like

What worked for me from your reply was the change of the server from the ā€œlocalhostā€ thatā€™s suggested everywhere, to ā€œcore-mosquitoā€ which is shown as the ā€œhostnameā€ for the Mosquito Broker add-on on itā€™s Info page.
I guess that shouldā€™ve been obvious from the name ā€œhostnameā€ :man_facepalming: but all the guides out there donā€™t mention it at all.

Hello guys,

Because i started this topic, at the end i remain to use ZHA with the latest firmware of conbee2
Itā€™s working fine with all my devices, and also you can change some zigbee quircks if one of the devices are not discovered correctly.

Hi,

I have also this error

[18:14:43] INFO: Preparing to startā€¦
[18:14:44] INFO: Socat not enabled
[18:14:45] INFO: Starting Zigbee2MQTTā€¦
Zigbee2MQTT:info 2022-11-13 18:14:47: Logging to console and directory: ā€˜/config/zigbee2mqtt/log/2022-11-13.18-14-47ā€™ filename: log.txt
Zigbee2MQTT:info 2022-11-13 18:14:47: Starting Zigbee2MQTT version 1.28.2 (commit #unknown)
Zigbee2MQTT:info 2022-11-13 18:14:47: Starting zigbee-herdsman (0.14.68)
Zigbee2MQTT:error 2022-11-13 18:15:07: Error while starting zigbee-herdsman
Zigbee2MQTT:error 2022-11-13 18:15:07: Failed to start zigbee
Zigbee2MQTT:error 2022-11-13 18:15:07: Check Zigbee2MQTT fails to start | Zigbee2MQTT for possible solutions
Zigbee2MQTT:error 2022-11-13 18:15:07: Exitingā€¦
Zigbee2MQTT:error 2022-11-13 18:15:07: Error: Failed to connect to the adapter (Error: SRSP - SYS - ping after 6000ms)
at ZStackAdapter.start (/app/node_modules/zigbee-herdsman/src/adapter/z-stack/adapter/zStackAdapter.ts:103:27)
at Controller.start (/app/node_modules/zigbee-herdsman/src/controller/controller.ts:132:29)
at Zigbee.start (/app/lib/zigbee.ts:58:27)
at Controller.start (/app/lib/controller.ts:101:27)
at start (/app/index.js:109:5)

cannot open zigbee2mqtt with error, 502: Bad Gateway and also my zigbee2mqtt is stopā€¦can somewone help please

thx,
nick

I have HA running as a VM in proxmox and got this 502 error after upgrading proxmox 6.3 to 7.4.

After much trial and error I discovered that the upgraded host had changed the name of the USB port and it was no longer maped through to the VM.

After remaping in the proxmox hardware settings and restarting HA Iā€™m back to normal.