Cannot connect new Esp32/8266 to Home assistant API (api.connection:083, connection closed)

Good Evening,
I’ ve been using EspHome for a long time now, but starting 3 days ago, I have not been able to connect any new Esp32/8266 with the API to Home assistant.
I’ ve attached the logs:



INFO Reading configuration /config/esphome/nodemcu1.yaml...
INFO Starting log output from nodemcu1.local using esphome API
INFO Successfully connected to nodemcu1.local
[18:13:13][I][app:102]: ESPHome version 2022.2.6 compiled on Mar 15 2022, 08:24:32
[18:13:13][C][wifi:491]: WiFi:
[18:13:13][C][wifi:353]:   Local MAC: -----
[18:13:13][C][wifi:354]:   SSID: [redacted]
[18:13:13][C][wifi:355]:   IP Address:----
[18:13:13][C][wifi:356]:   BSSID: [redacted]
[18:13:13][C][wifi:358]:   Hostname: 'nodemcu1'
[18:13:13][C][wifi:360]:   Signal strength: -78 dB ▂▄▆█
[18:13:13][V][wifi:362]:   Priority: 0.0
[18:13:13][C][wifi:364]:   Channel: 6
[18:13:13][C][wifi:365]:   Subnet: 255.255.255.0
[18:13:13][C][wifi:366]:   Gateway: 192.168.0.1
[18:13:13][C][wifi:367]:   DNS1: 8.8.8.8
[18:13:13][C][wifi:368]:   DNS2: 8.8.4.4
[18:13:13][C][logger:233]: Logger:
[18:13:13][C][logger:234]:   Level: VERY_VERBOSE
[18:13:13][C][logger:235]:   Log Baud Rate: 115200
[18:13:13][C][logger:236]:   Hardware UART: UART0
[18:13:13][C][captive_portal:144]: Captive Portal:
[18:13:13][C][mdns:084]: mDNS:
[18:13:13][C][mdns:085]:   Hostname: nodemcu1
[18:13:13][V][mdns:086]:   Services:
[18:13:13][V][mdns:088]:   - _esphomelib, _tcp, 6053
[18:13:13][V][mdns:090]:     TXT: version = 2022.2.6
[18:13:13][V][mdns:090]:     TXT: mac = b4e62d3bf8ac
[18:13:13][V][mdns:090]:     TXT: platform = ESP8266
[18:13:13][V][mdns:090]:     TXT: board = esp01_1m
[18:13:13][C][ota:085]: Over-The-Air Updates:
[18:13:13][C][ota:086]:   Address: nodemcu1.local:8266
[18:13:13][C][ota:089]:   Using Password.
[18:13:13][C][api:138]: API Server:
[18:13:13][C][api:139]:   Address: nodemcu1.local:6053
[18:13:13][C][api:143]:   Using noise encryption: NO
[18:13:28][VV][api.service:355]: on_ping_request: PingRequest {}
[18:13:28][VV][api.service:043]: send_ping_response: PingResponse {}
[18:13:34][VV][scheduler:185]: Running interval '' with interval=60000 last_execution=1133096 (now=1193101)
[18:13:43][VV][api.service:355]: on_ping_request: PingRequest {}
[18:13:43][VV][api.service:043]: send_ping_response: PingResponse {}
[18:13:58][VV][api.service:355]: on_ping_request: PingRequest {}
[18:13:58][VV][api.service:043]: send_ping_response: PingResponse {}
[18:14:11][D][api:102]: Accepted 192.168.0.106
[18:14:11][VV][api.service:319]: on_hello_request: HelloRequest {
  client_info: 'Home Assistant 2022.3.5'
}
[18:14:11][V][api.connection:808]: Hello from client: 'Home Assistant 2022.3.5 (192.168.0.106)'
[18:14:11][VV][api.service:013]: send_hello_response: HelloResponse {
  api_version_major: 1
  api_version_minor: 6
  server_info: 'nodemcu1 (esphome v2022.2.6)'
  name: 'nodemcu1'
}
[18:14:11][VV][api.socket:810]: Home Assistant 2022.3.5 (192.168.0.106): Connection closed
[18:14:11][W][api.connection:083]: Home Assistant 2022.3.5 (192.168.0.106): Connection closed
[18:14:11][V][api:114]: Removing connection to Home Assistant 2022.3.5 (192.168.0.106)
[18:14:13][VV][api.service:355]: on_ping_request: PingRequest {}
[18:14:13][VV][api.service:043]: send_ping_response: PingResponse {}

Thank you in advance!

i also have this issue:

[13:46:33][D][api:102]: Accepted ::xxxxx
[13:46:33][W][api.connection:083]: Home Assistant 2022.3.5 (::xxxxx): Connection closed

Something to do with the new api connection code noted in the changelog for ESPHome 2022.3.0?

[edit] - I see in the log that the version doesn’t match. So maybe the api connection changes in 2022.3.0 might help?

I have the same problem. However, I can’t say exactly when it started. HA and ESPHome are both current versions.
I posted it on Github 2 days ago, but haven’t received any help yet.
api.connection:083 and Display does not work · Issue #3151 · esphome/issues (github.com)

INFO Successfully uploaded program.
INFO Starting log output from /dev/ttyUSB1 with baud rate 115200
[11:58:54][I][logger:214]: Log initialized
[11:58:54][I][app:029]: Running through setup()...
[11:58:54][C][spi:023]: Setting up SPI bus...
[11:58:54][C][wifi:037]: Setting up WiFi...
[11:58:54][D][wifi:373]: Starting scan...
[11:58:56][D][wifi:388]: Found networks:
[11:58:56][I][wifi:432]: - 'FRITZ!Box 7490' [redacted]▂▄▆█
[11:58:56][D][wifi:433]:     Channel: 6
[11:58:56][D][wifi:434]:     RSSI: -71 dB
[11:58:56][I][wifi:432]: - 'FRITZ!Box 7490' [redacted]▂▄▆█
[11:58:56][D][wifi:433]:     Channel: 13
[11:58:56][D][wifi:434]:     RSSI: -77 dB
[11:58:56][D][wifi:437]: - [redacted] [redacted]▂▄▆█
[11:58:56][D][wifi:437]: - [redacted] [redacted]▂▄▆█
[11:58:56][I][wifi:248]: WiFi Connecting to 'FRITZ!Box 7490'...
[11:58:58][I][wifi:505]: WiFi Connected!
[11:58:58][C][wifi:353]:   Local MAC: F0:08:D1:D2:37:4C
[11:58:58][C][wifi:354]:   SSID: [redacted]
[11:58:58][C][wifi:355]:   IP Address: 192.168.178.58
[11:58:58][C][wifi:357]:   BSSID: [redacted]
[11:58:58][C][wifi:358]:   Hostname: 'anzeige1zoll'
[11:58:58][C][wifi:360]:   Signal strength: -72 dB ▂▄▆█
[11:58:58][C][wifi:364]:   Channel: 6
[11:58:58][C][wifi:365]:   Subnet: 255.255.255.0
[11:58:58][C][wifi:366]:   Gateway: 192.168.178.1
[11:58:58][C][wifi:367]:   DNS1: 192.168.178.1
[11:58:58][C][wifi:368]:   DNS2: 0.0.0.0
[11:58:58][D][wifi:514]: Disabling AP...
[11:58:58][C][api:025]: Setting up Home Assistant API server...
[11:58:58][I][app:062]: setup() finished successfully!
[11:58:58][I][app:102]: ESPHome version 2022.3.0 compiled on Mar 19 2022, 11:58:03
[11:58:58][C][wifi:491]: WiFi:
[11:58:58][C][wifi:353]:   Local MAC: F0:08:D1:D2:37:4C
[11:58:58][C][wifi:354]:   SSID: [redacted]
[11:58:58][C][wifi:355]:   IP Address: 192.168.178.58
[11:58:58][C][wifi:357]:   BSSID: [redacted]
[11:58:58][C][wifi:358]:   Hostname: 'anzeige1zoll'
[11:58:58][C][wifi:360]:   Signal strength: -72 dB ▂▄▆█
[11:58:58][C][wifi:364]:   Channel: 6
[11:58:58][C][wifi:365]:   Subnet: 255.255.255.0
[11:58:58][C][wifi:366]:   Gateway: 192.168.178.1
[11:58:58][C][wifi:367]:   DNS1: 192.168.178.1
[11:58:58][C][wifi:368]:   DNS2: 0.0.0.0
[11:58:58][C][logger:233]: Logger:
[11:58:58][C][logger:234]:   Level: DEBUG
[11:58:58][C][logger:235]:   Log Baud Rate: 115200
[11:58:58][C][logger:236]:   Hardware UART: UART0
[11:58:58][C][spi:097]: SPI bus:
[11:58:58][C][spi:098]:   CLK Pin: GPIO18
[11:58:58][C][spi:099]:   MISO Pin: GPIO19
[11:58:58][C][spi:100]:   MOSI Pin: GPIO23
[11:58:58][C][spi:102]:   Using HW SPI: YES
[11:58:58][C][homeassistant.time:010]: Home Assistant Time:
[11:58:58][C][homeassistant.time:011]:   Timezone: 'CET-1CEST,M3.5.0,M10.5.0/3'
[11:58:58][C][ili9341:030]: ili9341
[11:58:58][C][ili9341:030]:   Rotations: 90 °
[11:58:58][C][ili9341:030]:   Dimensions: 320px x 240px
[11:58:58][C][ili9341:031]:   Width: 240, Height: 320,  Rotation: 90
[11:58:58][C][ili9341:032]:   Reset Pin: GPIO33
[11:58:58][C][ili9341:033]:   DC Pin: GPIO27
[11:58:58][C][ili9341:035]:   Backlight Pin: GPIO32
[11:58:58][C][ili9341:036]:   Update Interval: 1.0s
[11:58:58][C][captive_portal:088]: Captive Portal:
[11:58:58][C][mdns:084]: mDNS:
[11:58:58][C][mdns:085]:   Hostname: anzeige1zoll
[11:58:58][C][api:138]: API Server:
[11:58:58][C][api:139]:   Address: anzeige1zoll.local:6053
[11:58:58][C][api:143]:   Using noise encryption: NO
[11:58:58][C][homeassistant.sensor:030]: Homeassistant Sensor 'outside_temperature1'
[11:58:58][C][homeassistant.sensor:030]:   State Class: ''
[11:58:58][C][homeassistant.sensor:030]:   Unit of Measurement: ''
[11:58:58][C][homeassistant.sensor:030]:   Accuracy Decimals: 1
[11:58:58][C][homeassistant.sensor:031]:   Entity ID: 'sensor.temperaturmelder_funk_2'
[11:58:58][C][homeassistant.sensor:030]: Homeassistant Sensor 'inside_temperature'
[11:58:58][C][homeassistant.sensor:030]:   State Class: ''
[11:58:58][C][homeassistant.sensor:030]:   Unit of Measurement: ''
[11:58:58][C][homeassistant.sensor:030]:   Accuracy Decimals: 1
[11:58:58][C][homeassistant.sensor:031]:   Entity ID: 'sensor.bme280_temperature_4'
[11:58:58][C][homeassistant.sensor:030]: Homeassistant Sensor 'aussen_temperature'
[11:58:58][C][homeassistant.sensor:030]:   State Class: ''
[11:58:58][C][homeassistant.sensor:030]:   Unit of Measurement: ''
[11:58:58][C][homeassistant.sensor:030]:   Accuracy Decimals: 1
[11:58:58][C][homeassistant.sensor:031]:   Entity ID: 'sensor.temperaturmelder_carport_2'
[11:59:23][D][api:102]: Accepted ::FFFF:C0A8:B251
[11:59:23][W][api.connection:083]: Home Assistant 2022.3.5 (::FFFF:C0A8:B251): Connection closed
[12:00:23][D][api:102]: Accepted ::FFFF:C0A8:B251
[12:00:23][W][api.connection:083]: Home Assistant 2022.3.5 (::FFFF:C0A8:B251): Connection closed
[12:01:23][D][api:102]: Accepted ::FFFF:C0A8:B251
[12:01:23][W][api.connection:083]: Home Assistant 2022.3.5 (::FFFF:C0A8:B251): Connection closed
[12:02:23][D][api:102]: Accepted ::FFFF:C0A8:B251
[12:02:23][W][api.connection:083]: Home Assistant 2022.3.5 (::FFFF:C0A8:B251): Connection closed
[12:03:23][D][api:102]: Accepted ::FFFF:C0A8:B251
[12:03:23][W][api.connection:083]: Home Assistant 2022.3.5 (::FFFF:C0A8:B251): Connection closed
[12:04:23][D][api:102]: Accepted ::FFFF:C0A8:B251
[12:04:23][W][api.connection:083]: Home Assistant 2022.3.5 (::FFFF:C0A8:B251): Connection closed
[12:05:24][D][api:102]: Accepted ::FFFF:C0A8:B251
[12:05:24][W][api.connection:083]: Home Assistant 2022.3.5 (::FFFF:C0A8:B251): Connection closed

So what i notice on my side is that the esp32 (logs) that it is trying to connect to an ipv6 addres. but internally i dont use ipv6. Maybe there lies an issue … ? …

Hi, I have this same issue, started around 3-4 weeks ago. But I don’t think it’s IPV6. Here is a snippet from issue #3108:

[16:05:05][D][sensor:124]: ‘Leslie Woofer Pulse Counter’: Sending state 0.00000 pulses/min with 2 decimals of accuracy
[16:05:07][D][api:102]: Accepted 192.168.1.173
[16:05:07][W][api.connection:083]: Home Assistant 2022.3.5 (192.168.1.173): Connection closed

Happens once a minute, just like you, no device can be found as a result.

I’ve seen a lot of posts about this recently here and on Reddit. Assumed it was wifi being wifi. Which inspired me to try a POE ESP32.

Aaaand this just dropped in the logs:
21:18:06 [W] [api.connection:083] ESPHome Logs 2022.3.0 (::FFFF:C0A8:60): Connection closed

Which doesn’t seem right since I monitor pings to it via PRTG and the worst-case is 3ms, which is waay better than my wifi ever was.

I just added a new esp32 wroom (to collect sensor data from water usage). Its the only esp32 (i use) with this issue. All the other esp’s are functioning (but where added earlier). This new esp only shows up in esphome on hassio. It it not discovered by hassio. So i can interact with it through esphome. But i cant use it in hassio…

good to mention;

  • hassio 2022.3.5 also hassio 2022.3.6
  • esphome 2022.3.0
    (latest as far as i can tell at the moment of writing)

I had some issues with IPV6 sneaking in. As a test, try adding:

network:
    enable_ipv6: false

And edit your esp32 section to include:

esp32:
  framework:
    type: esp-idf
    version: recommended

Ok i have to admit i made a mistake. The esp that was not showing up in hassio is a repurposed esp. The esphome integration still recognized it as the old configuration. And i totally glossed over it. So now i removed that old device and it showed up OK. Still see the disconnect error will try your proposed solution.

i’m stuck exactly in yours situation. using a repurposed esp32. i can’t figure out what i miss to delete. how did you exactly solved? thx

In the hassio integration’s menu (https://<hassio>/config/integrations) i looked at esphome. There u see all the device’s recognized. I deleted my old “configured esp” device and the “repurposed” esp showed up almost at the same time. Screenshot 2022-03-23 at 11.42.36

my fault i previously disable the old integration so it didn’t show. re added integration manually with ip address solved

I am having the exact same issue with a board today. There was an issue with the build so I just decided to wipe it and start again. Ever since the D1 Mini will just not connect to HA with the same errors above.

I have gone through and removed all traces of it within the ESPHome configs however even giving it a completely different name it just wont reconnect. I have refreshed the damned thing a dozen or so times tonight and getting the same outcome.

Something is being residual and preventing it reconnecting but I have run out of ideas of what else to delete. My guess there is some security reason why it is being refused but it would be nice to be able to “trust” or overrule it.

I have no other devices added within the ESPHome integration that have used this board. Could it be something with the MAC address when its connecting back to HA? Is there anything within HA that I also need to remove?

Tomorrow I am just going to try a fresh board and see what happens. I have reflashed and repurposed boards before and never had this problem. Is ESPHome just trying to be a bit to clever with HA now?

Good question.

I renamed an ESPHome device today in the yaml and immediately upon installing that change, repeated disconnects were logged over and over. Even though that device was added via IP to HA and mDNS disabled in the yaml.

Reverting the name change in the yaml fixed it.

No matter what I did with that board I just couldn’t get it to connect. Literally purged every reference of it within the config files and it just wouldn’t play ball.

I set up a new board this morning. Exact same name… installed the vanilla config using ESPHome-Flasher and boom connected straight away. Then copied the remainder of my code over and it behaved like the last 24 hour struggle with the last ESP didnt happen.

No solution other than a new board. I kind of expect me to break the board by being an idiot with my circuit design, not have ESPHome decide I dont trust this thing any more. If anything there should just be a ‘continue anyways’ warning like when you access a local web server with a self signed cert. I am all for security but I should be able to control how its implemented, considering I built the board and wrote the code!

I may be completely wrong with the issue here…

Fall here searching for the 'api.connection:083]: Home Assistant 2022.x.x (192.168.xx.xxx): Connection closed .
After reading here, it was related with a re-purposed unit and I have change names, etc o that device yesterday, I check integration, device and saw there were the old integration still living in the ESPHome devices list. So, delete old, and add new, like that:

devices & services -> ESPHome -> athom-smart-plug-v2-8fa343 (old name) -> delete -> devtools -> yaml-restart ->
New devices discovered notification (my-new-plug01) -> CONFIGURE (add) -> Congratulations! added -> FIXED!, no more yellow api error in log on that device.

Thanks for the comments here to get the solution.

How did you re-add it manually? I cannot see a way to add new devices through that interface in Integrations.

This solved my similiar problem - BUT I also had to reset the IP of the device so that ESPHome/HA genuinly percieved it as a new device, without this additional step it did not appear in the autodiscover.

Hi ebdavison, not sure if this is what you ask: