ESP32 Upload Failed: Timed Out Waiting for Packet Header

NodeMCU ESP8266 Development Board with 0.96 Inch OLED Display, CH340, ESP-12E WiFi Mod, additional view - Quality RC Parts

ESP32 Upload Failed: Timed Out Waiting for Packet Header

An ESP32 upload failed with timed out waiting for packet header when the chip never enters download mode. The fix is to hold the BOOT button, click Upload, and release BOOT when the output shows Connecting. If that fails, swap in a known USB data cable, confirm the port and board selection, and install the CH340 or CP2102 driver.

Quick facts

  • Exact error: A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header.
  • Cause: the chip did not enter download mode. The code is almost never the cause.
  • First fix: hold BOOT, click Upload, release BOOT at Connecting.
  • Boot pins to keep free during upload: GPIO 0, GPIO 2, GPIO 5, GPIO 12, GPIO 15.
  • Upload speed fallback: 115200 baud when 921600 fails on a long or thin cable.

What does the error mean?

The Arduino IDE sends your sketch with a tool called esptool. Esptool talks over the serial port to a bootloader stored in the chip ROM. For that bootloader to listen, the ESP32 must start with GPIO 0 held low at the moment of reset. On most dev boards, an auto-reset circuit does this for you. It uses the DTR and RTS lines from the USB-to-serial chip to pull the EN pin and GPIO 0 in the right order. When that sequence fails, esptool sends sync packets and gets no reply. After a row of dots, it prints Failed to connect to ESP32: Timed out waiting for packet header.

The error tells you the computer reached the port but the chip did not answer as expected. It does not mean the sketch is broken. It does not mean the board is dead. It means the download mode handshake failed. The fix list in this guide works in order of likelihood: BOOT button, cable, port, driver, board selection, then boot pins. Work it in order and change one thing at a time. A board that uploads only while you hold BOOT has a weak auto-reset circuit, and the capacitor fix at the end of this guide can help.

How do you enter download mode by hand?

Hold the BOOT button on the board. Click Upload in the IDE. Watch the output panel. When it prints Connecting with rows of dots, release the BOOT button. The upload should start at once. This sequence mimics the auto-reset circuit by hand. It holds GPIO 0 low during reset, so the ROM bootloader listens on the serial port. The timing matters. Release BOOT too early and the chip boots the old sketch. Release it after the upload starts and the transfer continues on its own. Practice the sequence twice and it becomes routine.

Some boards need a second step. Hold BOOT, press and release the EN button, then click Upload and release BOOT at Connecting. The EN button resets the chip while GPIO 0 stays low. The ESP32-CAM board often needs this sequence, because it lacks the reset circuitry of a full dev board. A bare ESP32-WROOM module on a custom board also needs manual boot mode. If your board has no BOOT button, connect GPIO 0 to ground with a jumper wire during the Connecting message, then remove the jumper when the upload starts. Do not leave GPIO 0 grounded after the upload, or the board will boot into download mode every time.

Is the cable or the port the problem?

Swap the cable first. Many USB cables carry power only, with no data wires inside. A charge-only cable powers the board, lights the LED, and still cannot upload. Use a short, good-quality data cable that you have used for file transfer. A cable longer than 3 feet adds resistance and noise, and it can fail an upload at 921600 baud. Try a rear USB port on a desktop computer, or a powered USB hub. A front panel port or an unpowered hub can drop the voltage during the upload handshake. The board may look fine and still fail to connect.

Check the port next. Open Tools, Port in Arduino IDE and confirm the port for your board is selected. Unplug the board and watch the port disappear, then plug it back in. If the port list does not change, the driver or the cable is at fault. On Windows, open Device Manager and look under Ports (COM and LPT). A CH340 board shows as USB-SERIAL CH340. A CP2102 board shows as Silicon Labs CP210x USB to UART Bridge. A yellow warning icon means the driver is missing. The driver fix guide in this series covers both chips. Close the Serial Monitor before you upload, because it holds the port open.

Is the board selection or the upload speed wrong?

Open Tools, Board and confirm the entry matches the chip on your board. A DevKit V1 board uses ESP32 Dev Module. An S3 DevKitC-1 board uses ESP32S3 Dev Module. A C3 SuperMini uses ESP32C3 Dev Module. The wrong entry can compile and still fail to upload, because the flash size and the upload settings differ. The board entry also sets the upload tool. An ESP32 entry will not upload to an ESP8266 board, and an ESP8266 entry will not upload to an ESP32 board. Match the entry to the chip on the module shield. The shield prints ESP32-WROOM-32, ESP32-S3-WROOM-1, or ESP32-C3-WROOM-02.

Lower the upload speed when the cable is long or the port is noisy. Open Tools, Upload Speed and set it to 115200. A slower upload is more tolerant of a poor cable. The upload takes longer, but it finishes. A speed of 921600 works on most boards with a good cable. A speed of 460800 is a middle step when 921600 fails and 115200 feels slow. In PlatformIO, set upload_speed = 115200 in platformio.ini. In esptool, use the -b 115200 option. Record the speed that works in your project notes, so the next upload starts from a known good value.

What is wired to the boot pins?

At startup, the ESP32 reads a few pins to decide how to boot. Those pins are called strapping pins. GPIO 0 selects download mode when it is low at reset. GPIO 2, GPIO 5, GPIO 12, and GPIO 15 also affect boot. A sensor, a display, or a motor driver wired to one of those pins can hold it in the wrong state during upload. Disconnect anything wired to GPIO 0, GPIO 2, GPIO 5, GPIO 12, and GPIO 15, then retry the upload. If the upload works with the circuit removed, the circuit was the cause. Move that part to a safe GPIO pin and keep the boot pins free in the final build. GPIO 5 affects SDIO timing and rarely blocks an upload, but it is a strapping pin, so keep it free during upload too.

The 10 microfarad capacitor fix helps boards with a weak auto-reset circuit. Connect a 10 uF electrolytic capacitor between the EN pin and ground, with the positive leg to EN. The capacitor delays the EN rise just enough for the auto-reset sequence to work. Remove the capacitor if it makes uploads worse, because some boards do not need it. A capacitor is a workaround, not a repair. A board that needs it will still need the BOOT button sequence sometimes. Keep the BOOT sequence as your first fix and the capacitor as a backup for a board you use every day.

How do you confirm the fix with esptool?

Use esptool from a terminal to test the connection without the IDE. Run esptool.py –chip esp32 –port PORT chip_id, with PORT replaced by your port name. Hold BOOT during the reset if the board needs manual boot mode. A chip ID reply proves the bootloader is reachable and the cable, driver, and port all work. No reply means the chain is still broken at the cable, driver, or boot pins. The chip_id test is faster than a full upload, because it does not compile a sketch first. Use it after each fix to confirm the change before you retry the upload.

If chip_id works but the IDE upload still fails, the fault is in the IDE settings. Check the board entry and the upload speed again. Close the Serial Monitor. Restart the IDE. A stale port lock from a crashed upload can hold the port after the IDE closes. Unplug the board, wait 5 seconds, and plug it back in. On Windows, a COM port can stay reserved after a failed upload. A restart of the IDE clears it. On Linux, check that no other process holds /dev/ttyUSB0. The command lsof /dev/ttyUSB0 lists the holder.

Step-by-step: ESP32 upload failed fix

  1. Read the output panel and confirm the error is Failed to connect to ESP32: Timed out waiting for packet header.
  2. Hold the BOOT button, click Upload, and release BOOT when the output shows Connecting.
  3. Swap in a short, known USB data cable and try a rear USB port or a powered hub.
  4. Open Tools, Port and pick the port that appears when you plug the board in. Close the Serial Monitor first.
  5. Install the driver for the USB chip on your board: CH340 from WCH or CP2102 from Silicon Labs.
  6. Open Tools, Board and confirm the entry matches the chip on your board.
  7. Lower the upload speed to 115200 in Tools, Upload Speed.
  8. Disconnect anything wired to GPIO 0, GPIO 2, GPIO 5, GPIO 12, and GPIO 15, then retry the upload.
  9. Test with esptool.py –chip esp32 –port PORT chip_id to confirm the bootloader answers.
  10. If the board uploads only with BOOT held, add a 10 uF capacitor between EN and ground as a workaround.

Error message and first fix

What you see What it means Do this first
Failed to connect: Timed out waiting for packet header Chip never entered download mode Hold BOOT at Connecting
Wrong boot mode detected (0x13) Chip booted normally, GPIO 0 was not low BOOT button sequence, or free GPIO 0
Invalid head of packet Serial data is corrupted Set upload speed to 115200, change the cable
Port is missing from Tools, Port Cable or driver fault Swap the cable, install the driver
Upload works only while holding BOOT Auto-reset circuit is weak or missing Keep the BOOT sequence, or add the EN capacitor

First code to run

Upload this sketch after the BOOT sequence works. It blinks the LED twice per second and prints Upload OK once at startup.

// Upload test sketch for ESP32
// Board: ESP32 Dev Module (DevKit V1)
// Library: none. Upload this after the BOOT sequence works.
// This sketch proves the upload, not the wiring. Keep the board bare.
void setup() {
  Serial.begin(115200);          // Start serial at 115200 baud
  pinMode(LED_BUILTIN, OUTPUT);  // GPIO 2 LED on a DevKit V1 board
  Serial.println("Upload OK");
}

void loop() {
  digitalWrite(LED_BUILTIN, HIGH);
  delay(500);
  digitalWrite(LED_BUILTIN, LOW);
  delay(500);
}

If this sketch uploads but a larger sketch fails, the fault is not the connection. Check the partition scheme and the sketch size in the flash and partition guide in this series.

Frequently asked questions

Why does my ESP32 upload fail only sometimes?

A weak auto-reset circuit or a marginal cable fails when the timing is tight. The BOOT button sequence fixes it every time. A shorter cable and a 115200 upload speed also help. A board that fails at random is not broken, but its auto-reset timing is on the edge.

Do I need to press BOOT on every upload?

No, on most dev boards. The auto-reset circuit handles it. Press BOOT only when the upload fails with a timeout. Boards without the circuit, such as ESP32-CAM, need the BOOT sequence on every upload.

Can a sensor on GPIO 0 block an upload?

Yes. GPIO 0 is a strapping pin. A sensor that pulls it low or high at reset changes the boot mode. Disconnect anything on GPIO 0, GPIO 2, GPIO 5, GPIO 12, and GPIO 15 during upload, then reconnect it after the upload finishes.

What upload speed should I use for ESP32?

Use 921600 on a good cable and 115200 when uploads fail. A slower speed is more tolerant of a long cable and a noisy port. The upload takes longer at 115200, but it finishes.

Does the ESP32-CAM need a different upload method?

Yes, in practice. ESP32-CAM boards often lack the auto-reset circuit. Hold BOOT during the Connecting message on every upload. The ESP32-CAM also needs a separate USB-to-serial adapter, because it has no USB port of its own.

Parts used in this guide

This guide fixes uploads on the ESP32 DevKit V1 board and the NodeMCU ESP8266 board linked below. The BOOT sequence, cable, and driver checks work for both chips.

Related guides

Sources

Last updated: 2026-11-21