ESP32 Wi-Fi keeps disconnecting: stable connection checklist

A connection that drops after it was working usually needs reconnect code, a steadier supply or a stronger signal. Do not assume WiFi.begin() once at start-up is enough.

What the message means

The ESP32 can lose the access point for many reasons: weak signal, a router that drops idle clients, a supply dip during radio bursts, or a long blocking loop. The board does not always reconnect on its own unless you ask it to.

Fix it in this order

  1. Call WiFi.setAutoReconnect(true) and also check WiFi.status() in loop(). If it is not connected, call WiFi.reconnect().
  2. Turn off Wi-Fi power saving with WiFi.setSleep(false) while you debug. It can reduce dropped connections at the cost of more current.
  3. Check the supply. Radio bursts draw current peaks, and a weak USB port or thin wire causes dropouts and resets.
  4. Move closer to the router or fix the antenna. A weak signal looks like random disconnects.
  5. Avoid long delay() calls and blocking loops. Keep loop() short so the Wi-Fi tasks get time.
  6. Check the router: too many clients, a short DHCP lease or a channel crowded with neighbours can drop devices. Try a fixed channel.
  7. Print the disconnect reason from the Wi-Fi event handler. It tells you if the access point kicked the board or the signal was lost.

Why it happens

Wi-Fi drops on an ESP32 usually come from a weak supply, a poor signal, the radio power-save mode, or code that never reconnects. The radio draws short, large current bursts, so a weak USB cable or port can cause brown-outs that look like disconnects.

Use a good supply with a capacitor near the board, move closer to the router, and add a reconnect step in code.

void loop() {
  if (WiFi.status() != WL_CONNECTED) {
    WiFi.disconnect();
    WiFi.reconnect();
    delay(5000);
  }
}
// WiFi.setSleep(false); in setup() turns off power-save if drops continue

Example sketch: change pins and values for your own wiring. It has not been bench-tested on your hardware.

If you see this, do this

You seeDo this
Drops every few minutesRouter lease or power-saving settings.
Drops when the motors runSupply dip. Separate the motor supply.
Drops far from the routerSignal strength.

ESP32 will not connect to Wi-Fi, ESP32 brownout, Wi-Fi controlled robot with ESP32.

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.