Source: https://mokxi.com/errors/esp32-failed-to-connect-wrong-boot-mode
Updated: 2026-11-17

Home / Errors
Arduino upload error

# A fatal error occurred: Failed to connect to ESP32: Wrong boot mode detected (0x13)! The chip needs to be in download mode.

To take a new program, the ESP32 has to start in download mode. The upload tool resets the chip and finds it running a program instead.

Run the sketch in Mokxi first See the causes

- Upload error
- 4 common causes

The message

## What the Arduino IDE prints

Output window

Most boards switch modes by themselves. The usual fault is the BOOT button, a pin held at the wrong level, or the cable.

Causes

## The 4 usual causes in order

### 1The BOOT button has to be held

Some boards do not reset into download mode on their own.

- Start the upload and wait for Connecting... to show in the output.
- Hold the BOOT button (often labeled IO0) until the percentage starts, then let go.
- If that works, a 10 uF capacitor between EN and GND on the board, or a better cable, often makes it automatic.

### 2Something holds GPIO0 or GPIO2 at the wrong level

The chip reads GPIO0 at reset to choose its mode. A wire or a module on that pin can force it to run mode.

- Unplug everything from GPIO0, GPIO2 and the TX and RX pins.
- Upload again, then reconnect the parts.

### 3The cable or the USB port gives too little power

A weak supply resets the chip in the middle of the upload.

- Try a short, good cable and a port on the computer itself.
- Keep motors and large LED strips off the board while uploading.

### 4The wrong port or board is selected

esptool talks to whatever is on the chosen port.

- In Tools, Port, pick the port that appears when you plug the board in.
- Pick the ESP32 board you actually have, for example ESP32 Dev Module.

On a real board

## What to do at the bench

Mokxi's Upload to board writes to a classic ESP32 from Chrome or Edge, through the same ROM bootloader esptool talks to, so the same causes stop it and the same fixes apply.

Run the sketch in Mokxi before you blame the board. If it builds and runs there, the code is fine and the problem is the connection to the real board.

### Test the sketch in Mokxi first

Run the sketch here before you blame the board. If it builds and runs in Mokxi, the code is fine and the fault is the connection to the real board. Mokxi never uploads in a simulation, so it cannot raise this error itself.

A sketch to try first

FAQ

## Questions and answers

### What does "Wrong boot mode detected (0x13)" mean?

The chip restarted into normal run mode, not download mode, so the upload tool found a running program and not the loader.

### Why does holding BOOT help?

BOOT pulls GPIO0 low while the chip resets. A low GPIO0 at reset selects download mode.

### Is it my code?

No. The sketch compiled, and the error happens before anything is written.

### Does it work in Mokxi?

The sketch runs there, because Mokxi simulates the board and does not upload. That tells you the code is fine.

Next

## More errors and the longer guide

- A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header
- Port not found

Every Arduino compile error All Arduino errors
