Source: https://mokxi.com/learn/esp32-not-connecting-to-wifi
Updated: 2026-10-26

Learn

# ESP32 not connecting to WiFi: read the status, then fix the cause

Beginner

Written by the Mokxi team, updated October 26, 2026

Start building free Open the editor

Or see every lesson.

- 455 parts on the bench
- 43 boards running now
- 1.00x real time, on every board

Click to open it in the editor

The connect loop prints its dots, then the address. Change the board’s wifiPassword to see it fail.

An ESP32 that will not join a network almost always tells you why, if you ask. WiFi.status() returns a number, and that number is different for a network it cannot find, a password it got wrong, and a join that is still in progress. Most connect loops in tutorials print a row of dots and never print the number, which is why the problem looks like a mystery.

First, plainly: in Mokxi the radio is simulated. There is no 802.11, the one access point a board can see is a setting on the board, and a password is compared as a string. Real internet is a switch you turn on when signed in. What is faithful is the code, the status numbers, the order they come in and the second or two a join takes. So this page can show you exactly what your sketch sees for each mistake in the code. The causes that live in the radio, the antenna and the power supply are real hardware, and they have their own section at the end.

The circuit above is an ESP32-C3 running the WiFi connect example. Press Run and it prints "status: connected", "took 2750 ms" and "IP address: 192.168.4.2". Click the board and change its wifiPassword property, and the same sketch prints "status: connect failed: wrong password". Change wifiSsid instead and it prints "status: no network with that name".

## Print the number WiFi.status() returns

This sketch calls WiFi.begin() once and then prints WiFi.status() every time it changes, with the time. On the simulated network with the right name and password it printed "WiFi.status() = 0" straight after begin(), then "200 ms: WiFi.status() = 6", then "2800 ms: WiFi.status() = 3", "IP address: 192.168.4.2" and "RSSI: -52".

The numbers are Arduino’s own wl_status_t, the same on an ESP32 on your desk. 0 is WL_IDLE_STATUS, 1 is WL_NO_SSID_AVAIL (no network with that name), 3 is WL_CONNECTED, 4 is WL_CONNECT_FAILED, 5 is WL_CONNECTION_LOST and 6 is WL_DISCONNECTED. There is no "connecting" value: a board that is still joining reports 6, which is why a loop that waits for 3 sees 6 for a second or two even when everything is right.

Print each change of WiFi.status(), with the time

## Status 4: the password is wrong

Change the password in the sketch to "wrong" and the same run prints "200 ms: WiFi.status() = 6" and then "5000 ms: WiFi.status() = 4". A board tries for a while before it gives up on a password, so a wrong one takes longer to report than a right one takes to connect. An empty password, "", against a network that has one ends in 4 too.

Passwords are case sensitive and every character counts, including a space at the end of a string you copied from a phone. Mokxi gives 4 for a wrong password, as Arduino’s WiFi reference describes. Some versions of the ESP32 core report a wrong password with another number, so a connect loop should also give up on a timeout rather than wait for 4 alone.

## Status 1: no network with that name

Put "MyHomeWiFi" in the sketch instead of the board’s network name and it prints "3000 ms: WiFi.status() = 1". The board looked and found no network with that name. Network names are case sensitive as well: "mokxi-lab" also ended in 1, after 1600 ms, and so did "Mokxi-Lab " with a space on the end, after 2500 ms.

A scan shows the name exactly as the board sees it. WiFi.scanNetworks() on the simulated network printed one line from Mokxi saying the scan is simulated, then "1 network(s) found" and "Mokxi-Lab". On real hardware, a network that is missing from the scan is one the board cannot hear at all, and the most common reason is in the hardware section below.

## Status 6 forever: begin() called over and over

A sketch that calls WiFi.begin() inside loop(), or in a retry loop that runs every half second, never connects. Every call starts the join again from the beginning. We ran exactly that with the right name and password, begin() then delay(500) then a print, and every line for five and a half seconds said 6. A join takes longer than the gap between the calls, here 2800 ms, so it never finishes.

Call begin() once, in setup(), and then wait. If you want to retry, wait ten seconds or so between tries, and call WiFi.disconnect() before the next begin().

## Giving up too soon

The opposite mistake is a loop that waits one second and then reports failure. The join in the sketch above took 2800 ms on the simulated network, which is a normal time for a real board on a quiet network too. A loop like the one in the sketch, with an eight to twenty second limit and the status printed at the end, tells you both that it failed and why.

## What Mokxi does not simulate

Everything in the sections above is the sketch’s side of the story, and the simulation shows it as a board would. The radio is not there. There are no channels, no signal to lose and no encryption; WiFi.RSSI() is the board’s wifiRssi setting and not a measurement, and WiFi.setTxPower() is accepted and changes nothing. A WiFi sketch cannot be uploaded from Mokxi to a real board yet; the build for hardware stops with "WiFi works in Mokxi only for now. Upload a sketch without WiFi, or use the Arduino IDE for this one."

## On real hardware: the radio, the power and the router

If the sketch is right and a real board still will not join, the cause is usually one of these. The ESP32, ESP32-S3, ESP32-C3 and ESP32-C6 radios use the 2.4 GHz band only, so a network that exists only at 5 GHz is invisible to them. Many routers give both bands the same name; give the 2.4 GHz one its own name, or join a phone hotspot set to 2.4 GHz, to test.

Power is next. The radio draws its current in short bursts when it starts to transmit, and a weak USB port, a long thin cable or a small regulator can sag far enough to reset the chip just as WiFi starts. A board that reboots each time it tries to connect, or that connects only on one cable, has a supply problem. On an ESP32-CAM, use a solid 5 V supply rather than a USB-serial adapter’s 3.3 V pin, and check that the antenna selection matches the antenna you are using.

The antenna matters on small boards. Keep metal, a hand and the breadboard’s rails away from it. Many ESP32-C3 SuperMini owners report that their boards only connect after lowering the transmit power with WiFi.setTxPower(WIFI_POWER_8_5dBm) right after WiFi.begin(). Finally, the router: a network set to WPA3 only, a school or office network that wants a user name as well as a password, a hotel network with a sign-in page, and a router that filters devices by MAC address will all refuse an ESP32 that does everything else right.

## Questions

What does WiFi.status() 6 mean on an ESP32?

WL_DISCONNECTED. Straight after WiFi.begin() it means the board is still joining, because Arduino has no "connecting" value. If it stays 6 for twenty seconds, or forever, check that begin() is not being called again and again.

What does WiFi.status() 1 mean?

WL_NO_SSID_AVAIL: the board found no network with the name you gave. Check the spelling, the capitals and any trailing space, and on real hardware that the network is on 2.4 GHz.

Why does my ESP32 connect sometimes and not other times?

On real hardware that is usually power or signal: a supply that sags when the radio transmits, or a board at the edge of the router’s range. The sketch’s side of a join is the same every time, so a fault that comes and goes is rarely in the code.

Can Mokxi connect my ESP32 sketch to my real WiFi?

No. The network is simulated, and with Real internet off nothing a sketch does reaches the internet the browser is on. Signed in, you can switch on Real internet so HTTP and HTTPS requests reach real hosts through Mokxi’s gateway. You can test the connect loop, the status codes, HTTP requests to a few made-up hosts and a web server the editor can open.

Related

## Keep going

Connect a Board to WiFi and Serve a Page Blink an LED on the ESP32-C3, Step by Step How to Debug Arduino Code: Prints to Breakpoints Arduino Serial Monitor Garbage or Blank: Fixes ESP32 Preferences Library: Save Settings, Example Help: the simulated WiFi, what works and what does not The ESP32-C3 simulator The ESP32 simulator The project page, with the full sketch Beginner

Sources

## Where the facts on this page come from

- Arduino reference: WiFi.status() and its values
- Espressif: the Arduino ESP32 Wi-Fi API

## Build this for real

Open the editor, change a value and watch the number move with it. Nothing to install, and no account needed.

Start building free Open the editor
