ESP32 will not connect to Wi-Fi: checks in order

If WiFi.status() never reaches WL_CONNECTED, check the band and the credentials before the code. The ESP32 joins 2.4 GHz networks only, and a typo in the name or password gives no useful error.

What the message means

WiFi.begin() starts the connection and returns immediately. The board keeps trying in the background. Status stays at WL_DISCONNECTED or WL_NO_SSID_AVAIL until the join succeeds or fails.

Fix it in this order

  1. Confirm the router broadcasts a 2.4 GHz network. A 5 GHz-only SSID cannot be joined.
  2. Check the SSID and password for case, spaces and look-alike characters. Print them to the serial monitor.
  3. Call WiFi.mode(WIFI_STA) before WiFi.begin() so the board acts as a client.
  4. Print WiFi.status() in a loop with a short delay and a time-out, instead of waiting forever.
  5. Move the board closer to the router. A weak signal fails the handshake.
  6. Try a phone hotspot on 2.4 GHz. If that works, the problem is a router setting such as WPA3-only mode or MAC filtering.
  7. Check the supply. A weak USB port can reset the board during the radio start-up.

Why it happens

The usual causes are a wrong network name or password, a router that only offers 5 GHz (the classic ESP32 supports 2.4 GHz only), a weak signal, or code that never waits for the connection. Printing the connection status shows which one you have.

#include <WiFi.h>
WiFi.mode(WIFI_STA);
WiFi.begin(SSID, PASS);
unsigned long t0 = millis();
while (WiFi.status() != WL_CONNECTED && millis() - t0 < 15000) { delay(250); Serial.print("."); }
Serial.println(WiFi.status() == WL_CONNECTED ? WiFi.localIP().toString() : "failed");

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

Check the name and password for case and hidden spaces, move closer to the router, and try a phone hotspot set to 2.4 GHz to separate a router setting from a board fault.

If you see this, do this

You seeDo this
Status is WL_NO_SSID_AVAILThe network name is not seen. Band, spelling or range.
Status is WL_CONNECT_FAILEDWrong password or a router security mode the board does not accept.
It connects, then dropsWeak signal or a weak supply.

ESP32 brownout, ESP32 pinout for robotics, MQTT on the 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.

Why this happens

Connecting involves several steps in sequence: scan for the network, authenticate with the router, then request an IP address through DHCP. WiFi.begin() only starts this process. Each failure point gives a different status code, which is why printing the status number beats guessing. In the Arduino core 0 is idle, 1 is no SSID available, 3 is connected, 4 is connect failed and 6 is disconnected.

The classic ESP32 radio supports 2.4 GHz only. A router that merges 2.4 and 5 GHz under one name usually works because the board finds the 2.4 GHz side, but a 5 GHz-only name is invisible to it. Signal strength also decides whether the authentication exchange finishes, which is why a board that works beside the router fails across the house.

How to confirm the cause

  • Run a scan and print the list. If your network name does not appear, the board cannot see it: wrong band, range, or a hidden name.
  • Look at each network’s RSSI in the scan. Values around minus 70 dBm or weaker are marginal for a reliable join.
  • Print WiFi.status() each second for about 15 seconds. The final number tells you whether the problem is finding the network or joining it.
  • Try a phone hotspot set to 2.4 GHz with a simple name and password. If it works, the problem is the router.
  • Check the router for WPA3-only mode, MAC filtering or a limit on connected devices.

Worked example

This scan sketch lists every network the board can hear with its channel and signal strength.

#include <WiFi.h>
void setup() {
  Serial.begin(115200);
  WiFi.mode(WIFI_STA);
  WiFi.disconnect();
  int n = WiFi.scanNetworks();
  for (int i = 0; i < n; i++)
    Serial.printf("%d: %s ch%d %ddBm\n", i, WiFi.SSID(i).c_str(), WiFi.channel(i), WiFi.RSSI(i));
}
void loop() {}

If your network is listed with a reasonable signal, the problem is the password or the security mode. If it is missing, work on band, range and name.

Common mistakes

  • Calling WiFi.begin() again and again inside loop(), which restarts the attempt each time.
  • Typing the name with a different capital letter or a trailing space.
  • Using a phone hotspot that is set to 5 GHz only.
  • Waiting only a second or two before deciding it failed; joining often takes several seconds.

If this did not fix it

  • Weak power: a poor USB port can reset the board when the radio starts.
  • Hidden network name: a hidden name needs the correct name in code and may need a scan first.
  • Router with a small DHCP pool or a client limit: the join works but no address is given.