WARNING Can't connect to ESPHome API for XYZ.local: Error resolving IP address: [Errno -2] Name or service not known

dont know what is going on ?

Welcome to the forum.

Please read here, and then ask properly. How to help us help you - or How to ask a good question

Sorry to revive this old post but I seem to have the same error message. My Sonoff basic, which connected fine to ESPHome previously, fails to do so after changing the hostname from dining-room-climate to climate_dr. After flashing, I noted the underscore is not supported, and corrected it to climate-dr.

My other Sonoffs connect successfully with
INFO Successfully connected to climate-lr @ 192.168.0.112 in 0.008s

The problematic Sonoff produces this error. I noted the climate-dr.local, which does not appear in the logs of my other Sonoff under ESPHome logs.

INFO Successfully compiled program. INFO Resolving IP address of climate-dr.local ERROR Error resolving IP address of climate-dr.local. Is it connected to WiFi? ERROR (If this error persists, please set a static IP address: https://esphome.io/components/wifi.html#manual-ips) ERROR Error resolving IP address: Error resolving address with mDNS: Did not respond. Maybe the device is offline., [Errno -5] No address associated with hostname'

I have reflashed, I have cleared the build files and flashed. I’ve uploaded the binary via ESPHome web and see if I could edit the WIFI credentials (desparate now). The log here produces
Socket operation failed: HANDSHAKESTATE_READ_FAILED errno=11
Trying to configure the WIFI credentials produces
An error occurred. Improv Wi-Fi Serial not detected

I’m stuck.