Failed to connect to ESP32: Timed out waiting for packet header
Short answer: the flasher reached the serial port but the ESP32 never entered download (bootloader) mode, so it sent nothing back. On most boards you fix it by holding the BOOT button while flashing starts (release it once you see progress), and by using a USB data cable, not a charge-only one. Boards without auto-reset: hold BOOT, tap RESET, then release BOOT.
The full message is:
A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet headerWhat it means
esptool opened the serial port and tried to sync with the ESP32's ROM bootloader, but received no valid response before the timeout. It's almost always a download-mode, cable, driver, or power problem — not a dead board.
Fixes, in order
- Put the board in download mode. Hold
BOOT(some boards label itFLASHorIO0), then start flashing; releaseBOOTonce progress appears. Boards without auto-reset (many ESP32-S2/-S3 native-USB boards): holdBOOT, tapRESET/ENwhile holding, then releaseBOOT. Details: Wrong boot mode / download mode. - Use a USB data cable. Charge-only cables have no data lines, so the board won't sync (and the port may not appear). Swap the cable and plug directly into the computer, not through a hub.
- Install the USB-serial driver if your OS never shows the port — CP2102, CH340, or CH9102 depending on the board.
- Remove anything on
IO0/3V3. A wired peripheral can hold the chip out of download mode — disconnect it. On the command line, esptool suggests testing with-b 9600to rule out a baud-rate issue. - Check power. A weak USB port or long cable can brown the board out mid-sync — use a short cable or a powered hub.
If it keeps happening on a bare module, a 10 µF capacitor between EN and GND stabilises the auto-reset (a well-known ESP32 fix; 1–100 µF also reported to work).
Sources
- Espressif esptool docs — "Failed to connect" troubleshooting (official: correct port, close other terminals, stable 3.3 V, boot-mode pins,
-b 9600). - esptool issue #226 — "Failed to connect to ESP32: Timed out waiting for packet header (ESPTOOL-312)".
- Random Nerd Tutorials — "Solved: Failed to connect to ESP32…" (BOOT button, data cable, EN–GND capacitor, power).
Checked 2026-07.