Can I change IP address over the air?

I currently have an ESP32 using DHCP to get its IP address and now want to give it a different fixed address in the same subnet.

Is there a way to recompile with the new fixed address and reprogram OTA?

When I try to set the IP address to (was, I generate the following log

INFO Reading configuration /config/esphome/temp.yaml…
INFO Detected timezone ‘AEST’ with UTC offset 10 and daylight savings time from 04 October 02:00:00 to 04 April 03:00:00
INFO Generating C++ source…
INFO Compiling app…
INFO Running: platformio run -d /config/esphome/temp
Processing temp (board: d1; framework: arduino; platform: [email protected])

HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash
Dependency Graph
|-- 1.2.2
| |-- 1.0
|-- 1.0
|-- 1.2
| |-- 1.0
|-- 1.0
Compiling /data/temp/.pioenvs/temp/src/main.cpp.o
Linking /data/temp/.pioenvs/temp/firmware.elf
Retrieving maximum program size /data/temp/.pioenvs/temp/firmware.elf
Checking size /data/temp/.pioenvs/temp/firmware.elf
Building /data/temp/.pioenvs/temp/firmware.bin
DATA: [===== ] 46.2% (used 37888 bytes from 81920 bytes)
PROGRAM: [==== ] 40.1% (used 419044 bytes from 1044464 bytes)
Creating BIN file “/data/temp/.pioenvs/temp/firmware.bin” using “/data/temp/.pioenvs/temp/firmware.elf”
========================= [SUCCESS] Took 34.69 seconds =========================
INFO Successfully compiled program.
INFO Connecting to
ERROR Connecting to failed: [Errno 113] No route to host


1 Like

Yes check that:

The explanation Changing ESPHome Node Name can be used for The same procedure can be done for changing the static IP of a device.

Tell us if you success or not.


It’s a bit of a catch 22
You set a static IP in config to change the address, but the ota flashing uses that new address to try and contact the device BEFORE the new address has been set.

You have two options from what I can see.

  1. Upload the new firmware over a wire.
  2. Set a static IP for your device in your routers config, reboot the device so it takes the new IP, then upload the new firmware. This sort of defeats the purpose though as you’re already setting the address, just on the router side rather than in the ESPhome config.
1 Like

Have you tried to set the --upload-port to

esphome <CONFIG.yaml> upload --upload-port


Where do you run that command from ?

Thanks Adorem for the link it works well.

All that needs to be done is add another line in the ,yaml file under the wifi: section use_address: This forces the code to be accessed at .21, even though the new address is .221.

One catch is that after the initial load the log fails as it is still pointing to the old IP address, .21. What you need to do is go back and edit the .yaml file to remove the use_address line. Then click on Show Logs and the log will work with the correct IP address, .221.

Thanks for the help.


esphome <CONFIG.yaml> upload --upload-port

this is the command line option I usually use, however I tend to use run always as upload will not compile the code if you’ve made changes.