ERROR Error resolving IP address of ['foo.local']

I recently built a new ESPhome device. After performing the initial flash via USB, it showed up fine in ESPHome Builder, but I ran into an issue trying to flash my new config:

INFO Successfully compiled program.
ERROR Error resolving IP address of ['foo.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 Timeout resolving IP address: Timeout while resolving IP address for ['foo.local']
WARNING Failed to upload to ['foo.local']

I haven’t had this issue with other ESPHome devices I’ve built (mainly re-flashed Emporia smart plugs).

If I add the assigned IP to wifi: config

use_address: 192.168.1.123

it works, but I don’t want this to have a static IP.

I don’t think this is an mDNS issue as nothing else is broken, but I’m honestly at a loss here.

It’s not a static IP address, it just tells the compiler to upload the file to this device instead of looking it up.

As long as everything is working now, I honestly wouldn’t worry about it. Comment out the use_address part and add a note about why and when you originally used it for your future self. Very occasionally I’ll have an ESPHome device that for whatever reason has temporary mdns issues when updating and I’ll do just this.

Thanks for the advice.

I assume I will need to uncomment it and update the IP to whatever the current one is if I want to change the config in the future, right?

Yeah, if the same issue presents itself.

In my cases, it’s usually just random and transitory; I use DHCP for all my ESPHome devices and I assume an address happened to change recently and there’s a cache issue somewhere in the chain.

Mine seems to be constant, for this device at least. I feel better knowing that the specified address is just for the upload, but I’m still curious what is causing it with this particular config. my suspicion is that it’s related to a web_server component, but that’s only a guess.

I would suggest posting your full YAML.

---
substitutions:
  id_prefix: ratgdo1
  friendly_name: "RATGDO-1"  
  uart_tx_pin: GPIO13
  uart_rx_pin: GPIO12
  input_obst_pin: GPIO9
  status_door_pin: GPIO8
  status_obstruction_pin: GPIO7
  dry_contact_open_pin: GPIO16
  dry_contact_close_pin: GPIO15
  dry_contact_light_pin: GPIO14

web_server:

esphome:
  name: ${id_prefix}
  friendly_name: ${friendly_name}
  name_add_mac_suffix: true
  project:
    name: ratgdo.v25board_esp32_secplusv1
    version: "2.5"

esp32:
  variant: esp32s3
  framework:
    type: arduino

dashboard_import:
  package_import_url: github://ratgdo/esphome-ratgdo/v25board_esp32_d1_mini_secplusv1.yaml@main

packages:
  remote_package:
    url: https://github.com/ratgdo/esphome-ratgdo
    files: [base_secplusv1.yaml]
    refresh: 1s

# Sync time with Home Assistant.
time:
  - platform: homeassistant
    id: homeassistant_time

api:
  id: api_server

improv_serial:

logger:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

I think I figured it out, this was the problem:

  name_add_mac_suffix: True

I’m not 100% sure what’s happening here, but somehow the actual mDNS of the device and what the uploader thinks the mDNS of the device should be are out of sync.

The uploader is trying to resolve radgdo1.local, while the actual mDNS is ratgdo1-123456.local (whatever my last 3 MAC bytes are).

I was able to fix it by setting that to false, re-uploading with the IP specified, and then removing the IP. Subsequent uploads without the specified IP worked fine as mDNS resolved.

I managed to get it to use the MAC suffix mDNS name once as well, but I have since changed it back in an effort to understand this and have not gotten it to work again.

So to summarize, my device had the name “ratgdo1-123456”, and if I browse to ratgdo1-123456.local it loads the webserver I expect, but even though

  name_add_mac_suffix: True

is in my config, it still tries to resolve “ratgdo1.local” when uploading, throwing this error:

INFO Successfully compiled program.
ERROR Error resolving IP address of ['ratgdo1.local']. Is it connected to WiFi?