# ESP32 OTA update fails: partition space, network and password

> Fix ESP32 over-the-air updates that fail: the partition scheme needs two app slots, the PC and board on one network, and the OTA password.

Canonical: https://roboticsengineering.in/fix/esp32-ota-update-fails-no-space-or-wrong-network/ | Published: 2026-11-03 | Updated: 2026-11-04

**OTA needs room for a second copy of the program, so the partition scheme must have two app slots.** Check that first.

## What the message means

An OTA update writes the new program into an unused slot while the old one runs. A scheme with one big app slot cannot do that.

## Fix it in this order

1. Choose a partition scheme that includes OTA slots, and make sure the new program fits in one slot.
2. Put the computer and the ESP32 on the same network, and check that the firewall allows the OTA port.
3. Call the OTA handler in loop() often. Long blocking code stops the update.
4. Use the same OTA password in the sketch and in the upload tool.
5. Keep a first upload over USB so you can recover if an OTA program is faulty.
6. Keep power steady during the update.

## Why it happens

Over-the-air updates write the new firmware into a second application slot while the current program keeps running. The partition table reserves those slots in flash. If the layout has only one large app partition, there is no free slot, so the update cannot start. The fix is a partition layout with two app slots, sized so the new program fits within one of them.

The network path is a separate problem. The computer must reach the board on the same local network, and the OTA port must be allowed through any firewall. The uploader and the sketch must use the same OTA password. Long blocking code in loop() can also stop the handler from answering, so the update stalls or drops and looks like a network fault.

## If you see this, do this

| You see | Do this |
| --- | --- |
| Fails at the start | Network, firewall or password. |
| Fails near the end | Not enough space, or power dropped. |

## Confirm the fix

1. Print ESP.getFreeSketchSpace() in setup and compare it with the compiled binary size. The binary must be smaller.
2. Ping the board’s IP address from the computer on the same network. A reply confirms the network path before you try the upload again.
3. Upload over USB first, then push a sketch over OTA that prints a version string. Seeing the new version after reboot confirms success.

**Common mistake:** Many readers assume that a failed over-the-air update means the network is broken, when a common cause is that the partition layout has no room for a second program.

## Related

[Wi-Fi keeps disconnecting](https://roboticsengineering.in/fix/esp32-wifi-keeps-disconnecting/), [partition and file system](https://roboticsengineering.in/fix/esp32-spiffs-littlefs-mount-failed/).

Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.
