A static address must be in the router range, outside its automatic pool, with the correct gateway, subnet and DNS.
What the message means
Without correct settings the board joins Wi-Fi but cannot reach the router or the internet, or it clashes with another device.
Fix it in this order
- Read the router address and subnet mask from a computer on the same network.
- Pick an address in the same range that no other device uses, ideally outside the automatic pool.
- Call WiFi.config with the address, gateway, subnet and a DNS server before WiFi.begin().
- Set DNS to the router address or a public DNS server so names resolve.
- Or reserve the address in the router for the board and keep automatic settings.
- Test with ping from a computer.
Why it happens
A static IP must be on the same network as the router: the first three numbers match and the last one is free and outside the router DHCP range. The gateway is normally the router address. Call WiFi.config() before WiFi.begin().
Check the router address and subnet, choose an unused address, pass IP, gateway, subnet and DNS in the right order, and test with a ping.
IPAddress ip(192,168,1,50), gw(192,168,1,1), mask(255,255,255,0), dns(8,8,8,8);
WiFi.config(ip, gw, mask, dns);
WiFi.begin(SSID, PASS);
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 see | Do this |
|---|---|
| Joins Wi-Fi, no internet | DNS or gateway. |
| Disconnects now and then | Address clash. |
Related
Wi-Fi will not connect, web server not reachable.
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
An IP address has two parts, the network part and the host part, and the subnet mask says where the split is. With the mask 255.255.255.0, the first three numbers must match the router and only the last one may differ. Two devices on one network cannot share the same address, and the router normally hands out addresses from a pool by DHCP. A fixed address must therefore be on the same network, unused, and best placed outside that pool.
The gateway is the address of the router, which is where traffic to other networks goes. DNS turns names into addresses. If the gateway is wrong, the board joins the Wi-Fi but cannot reach beyond it. If DNS is wrong, it connects by number but fails by name.
How to confirm the cause
- On a computer on the same network, read its address, subnet mask and gateway. Ethernet or Wi-Fi details, or ipconfig on Windows, show them.
- Choose an address in the same network that no other device uses. Ping it from the computer before you use it. If it replies, it is taken.
- After the board connects, print WiFi.localIP(), WiFi.gatewayIP(), WiFi.subnetMask() and WiFi.dnsIP() to confirm what it really received.
- Ping the board from the computer. If it replies, the address works on the local network.
- From the board, request a web page by name. If the address works but the name fails, DNS is the issue.
Worked example
Suppose the router is 192.168.1.1 with mask 255.255.255.0 and gives DHCP addresses from 192.168.1.100 to 192.168.1.199. The address 192.168.1.50 is on the network (192.168.1.x), outside the pool, and not the router’s. This sketch sets it and prints what the board got.
#include <WiFi.h>
IPAddress ip(192,168,1,50), gw(192,168,1,1), mask(255,255,255,0), dns(8,8,8,8);
void setup() {
Serial.begin(115200);
WiFi.config(ip, gw, mask, dns); // before begin()
WiFi.begin("SSID", "PASSWORD");
while (WiFi.status() != WL_CONNECTED) delay(300);
Serial.println(WiFi.localIP());
Serial.println(WiFi.gatewayIP());
Serial.println(WiFi.dnsIP());
}
void loop() {}Common mistakes
- Calling WiFi.config() after WiFi.begin().
- Mixing the argument order. It is address, gateway, subnet, then DNS.
- Choosing an address inside the router’s DHCP pool.
- Copying a network setting from another home or office with a different range.
- Leaving DNS at 0.0.0.0, so names never resolve.
If this did not fix it
- A router setting that blocks new devices or limits them to a list of known addresses.
- Another device on the same address, which causes the board to drop on and off.
- A router with a different mask, such as 255.255.0.0, which changes what counts as the same network.