ESP Home stopped working - Bad Gateway 502

Hello Guys,

Hoping that someone can help.

In a nutshell I can getting bade gateway 502 when opening the UI.

I have tried to update to the latest HA and ESPhome. - no change
I have un installed and re installed ESP home - no change

I have read around on the internet and found that replacing voluptous 0.1.1.7 (latest) back to 0.1.1.5 should fix it. Problem being that I dont know how to do this…

Anyone got any ideas.

Rob

How are you running esphome? Via docker, or hassio add-on or something else?

Hassio addon

Esphome log

[21:34:10] INFO: Starting ESPHome dashboard…
Traceback (most recent call last):
File “/usr/local/bin/esphome”, line 11, in
load_entry_point(‘esphome==1.14.0.dev0’, ‘console_scripts’, ‘esphome’)()
File “/usr/local/lib/python2.7/dist-packages/pkg_resources/init.py”, line 489, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File “/usr/local/lib/python2.7/dist-packages/pkg_resources/init.py”, line 2852, in load_entry_point
return ep.load()
File “/usr/local/lib/python2.7/dist-packages/pkg_resources/init.py”, line 2443, in load
return self.resolve()
File “/usr/local/lib/python2.7/dist-packages/pkg_resources/init.py”, line 2449, in resolve
module = import(self.module_name, fromlist=[‘name’], level=0)
File “/usr/local/lib/python2.7/dist-packages/esphome/main.py”, line 10, in
from esphome import const, writer, yaml_util
File “/usr/local/lib/python2.7/dist-packages/esphome/writer.py”, line 7, in
from esphome.config import iter_components
File “/usr/local/lib/python2.7/dist-packages/esphome/config.py”, line 15, in
from esphome import core, core_config, yaml_util
File “/usr/local/lib/python2.7/dist-packages/esphome/core_config.py”, line 6, in
import esphome.config_validation as cv
File “/usr/local/lib/python2.7/dist-packages/esphome/config_validation.py”, line 1244, in
Optional(CONF_COMMAND_TOPIC): All(requires_component(‘mqtt’), subscribe_topic),
File “/usr/local/lib/python2.7/dist-packages/esphome/voluptuous_schema.py”, line 198, in extend
ret = super(_Schema, self).extend(schema, extra=extra)
File “/usr/local/lib/python2.7/dist-packages/voluptuous/schema_builder.py”, line 782, in extend
return result_cls(result, required=result_required, extra=result_extra)
TypeError: init() got an unexpected keyword argument ‘required’

I also get the same error. ESP home stable still works but loading the DEV version and stopping the stable version gives the same error when accessing the GUI. Going back and starting the stable version, everything works. Is it a problem with INgress?

1 Like

At a guess, dev is not guaranteed to work on every occasion.

1 Like

I had this issue with the DEV ESPHome addon, but I think it was some other error in log, but remeber that it said invalid required or something.
Got it working when I added
“ssl”: false
Into the options configuration box.
You probably already have:
{
“esphome_version”: “dev”
}
So just add it to look like so

{
    "esphome_version": "dev",
    "ssl": false
}
1 Like

That cures the problem. Thanks!

image

I have this set up.

But it broken. Ill try the other version. Didn’t realise that the Dev version could be dodgey.

Rob

1 Like

Just to confirm, I installed the non Dev version and I am back up and working :slight_smile:

Rob

It seems that the dev branch updates itself in the background.
While it is updating, you get

502: Bad Gateway.

As soon as it finishes the Web UI comes back.
But, unfortunately, nothing to tell you that.
You need to monitor the logs and click “Refresh”.
Here is a copy of the tail:

Successfully installed bottle-0.12.18 certifi-2019.11.28 colorama-0.4.3 esphome-1.15.0.dev0 semantic-version-2.8.4 setuptools-45.1.0 tabulate-0.8.6 urllib3-1.25.7
[cont-init.d] 30-esphome.sh: exited 0.
[cont-init.d] 40-migrate.sh: executing... 
[cont-init.d] 40-migrate.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[14:20:56] INFO: Waiting for dashboard to come up...
[14:20:56] INFO: Starting ESPHome dashboard...
INFO Starting dashboard web server on unix socket /var/run/esphome.sock and configuration dir /config/esphome...
[14:21:01] INFO: Starting NGINX...
INFO 200 GET / (0.0.0.0) 103.96ms
INFO 304 GET /static/fonts/material-icons.css?hash=ead4c276 (0.0.0.0) 46.91ms
INFO 304 GET /static/materialize.min.css?hash=ec1df3ba (0.0.0.0) 9.59ms
INFO 304 GET /static/materialize-stepper.min.css?hash=a7ad7ee2 (0.0.0.0) 6.37ms
INFO 304 GET /static/esphome.css?hash=33d0115f (0.0.0.0) 6.78ms
INFO 304 GET /static/jquery.min.js?hash=2f6b11a7 (0.0.0.0) 8.37ms
INFO 304 GET /static/jquery-ui.min.js?hash=a0b1425d (0.0.0.0) 9.52ms
INFO 304 GET /static/materialize.min.js?hash=4be20daf (0.0.0.0) 9.40ms
INFO 304 GET /static/jquery.validate.min.js?hash=b2d2cf16 (0.0.0.0) 6.67ms
INFO 304 GET /static/materialize-stepper.min.js?hash=9f34c4ff (0.0.0.0) 6.55ms
INFO 304 GET /static/ace.js?hash=2280cf05 (0.0.0.0) 12.30ms
INFO 304 GET /static/esphome.js?hash=2825ee86 (0.0.0.0) 6.71ms
INFO 304 GET /static/fonts/MaterialIcons-Regular.woff2 (0.0.0.0) 5.44ms

The Web UI started after nginx started.

And it seems to happen every time that ESPHOME is started or restarted, even if they report the same versions.

I’m running Home Assistant in Ubuntu 20.04 LTS docker and I got the 502 Bad Gateway with ESPHome addon when going to ESPHome web home. I had to disable my firewall and then it started working. “sudo ufw disable”

are you also running esphome dev?

I installed ESPHome as a normal addon in Home Assistant

I think that the ‘dev’ version checks every time for all updates and downloads and installs them. This can take some time and is time dependant on a fast internet connection. The other ‘versions’ may check (I am not sure if there is a setting for this) and so the time to check is much quicker.
So for ‘dev’ install the ‘bad gateway’ message occurs for a lot longer than it does for the ‘version’ install, but I have seen it for both types of installs

Hi to everyone.
I am experiencing the same Bad gateway error at the moment with my EspHome on HASIO. This error popped up on the recent updates (approx 3 months ago).
Currently I am using this versions of the system:
core-2022.7.6
Home Assistant OS 8.2
supervisor-2022.07.0

I have fathced some errors from the logs.
this one from the system logs:

Could not fetch stats for a0d7b954_esphome: Container addon_a0d7b954_esphome is not running
10:22:56 AM – (WARNING) Home Assistant Supervisor - message first occurred at 10:17:56 AM and shows up 2 times

Failed to to call /addons/a0d7b954_esphome/stats - Container addon_a0d7b954_esphome is not running
10:22:19 AM – (ERROR) Home Assistant Supervisor - message first occurred at 10:21:23 AM and shows up 2 times

Error handling request
1:45:19 AM – (ERROR) /usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py - message first occurred at July 24, 2022 at 11:36:19 PM and shows up 3 times

Logger: homeassistant.components.hassio
Source: components/hassio/websocket_api.py:122
Integration: Home Assistant Supervisor (documentation, issues)
First occurred: 10:21:23 AM (2 occurrences)
Last logged: 10:22:19 AM

Failed to to call /addons/a0d7b954_esphome/stats - Container addon_a0d7b954_esphome is not running

Logger: aiohttp.server
Source: /usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py:405
First occurred: July 24, 2022 at 11:36:19 PM (3 occurrences)
Last logged: 1:45:19 AM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 334, in data_received
    messages, upgraded, tail = self._request_parser.feed_data(data)
  File "aiohttp/_http_parser.pyx", line 551, in aiohttp._http_parser.HttpParser.feed_data
aiohttp.http_exceptions.BadHttpMessage: 400, message='Pause on PRI/Upgrade'

this one from the EspHome addon logs:


[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] 00-banner.sh: executing... 
exec: fatal: unable to exec /usr/bin/justc-envdir: Exec format error
[cont-init.d] 00-banner.sh: exited 126.
[cont-finish.d] executing container finish scripts...
[cont-finish.d] 99-message.sh: executing... 
-----------------------------------------------------------
                Oops! Something went wrong.

 We are so sorry, but something went terribly wrong when
 starting or running this add-on.
 
 Be sure to check the log above, line by line, for hints.
-----------------------------------------------------------
[cont-finish.d] 99-message.sh: exited 0.
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.

I am not using the DEV version of the addon.
This problem now persists for several days and it want go away by itself like somone mentioned in this post.

Can anybody help me?
BR,
Jure

Well what version are you using?

ESPHome
Current version: 2022.3.1

Update then :slight_smile:

1 Like

Ummm, yes, as simple as that.
Current version: 2022.6.2

Now we are up and running.

I was pretty sure I was running the latest version, sicne I had the auto-update option ON.

Thanks a lot!!
BR, Jure