You're sitting at your desk, laptop shows full Wi-Fi bars, but nothing loads. Not even Google. You open ping 8.8.8.8 in a terminal — and it replies. But ping google.com fails with Name or service not known. That's the signature. You're connected to the local network but your device can't resolve domain names. The IP route works, but DNS is broken. Or sometimes even ping 8.8.8.8 fails, which means the default gateway itself is unreachable.
The root cause is almost always one of two things: DNS configuration got corrupted (often after switching networks, waking from sleep, or VPN disconnects), or the router's DHCP failed to hand out a valid default gateway. I've seen this happen when a hotel's captive portal times out, when a Windows update resets the network adapter, or when you run a VPN that doesn't clean up after itself.
Step 1: Confirm the actual problem
Open a terminal and run:
ping 8.8.8.8
ping google.com
- If both fail: the issue is with the default gateway (your router). Skip to Step 3.
- If
8.8.8.8works butgoogle.comfails: DNS is broken. Do Step 2.
Step 2: Fix DNS — the quick way
Set a public DNS server manually. I use 1.1.1.1 (Cloudflare) and 9.9.9.9 (Quad9). Google's 8.8.8.8 works too, but Cloudflare is faster in most regions.
On Windows 10/11
- Open Control Panel > Network and Sharing Center > Change adapter settings.
- Right-click your active Wi-Fi adapter, choose Properties.
- Select Internet Protocol Version 4 (TCP/IPv4) and click Properties.
- Choose Use the following DNS server addresses.
- Set Preferred to
1.1.1.1, Alternate to9.9.9.9. - Click OK, then close everything. Run
ipconfig /flushdnsin Command Prompt as admin.
On macOS (Sonoma, Ventura, etc.)
- Go to System Settings > Network > Wi-Fi > Details.
- Click DNS, remove any existing entries.
- Add
1.1.1.1and9.9.9.9. - Click OK, then run
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponderin Terminal.
On Linux (Ubuntu/Debian/Fedora with NetworkManager)
- Edit
/etc/resolv.confwithsudo nano /etc/resolv.conf. - Replace contents with:
nameserver 1.1.1.1 nameserver 9.9.9.9 - Save and exit. If your distro uses
systemd-resolved, runsudo systemctl restart systemd-resolved.
Step 3: Fix the default gateway
If ping 8.8.8.8 also fails, your device has no route to the internet. This happens when DHCP fails or the router's IP changed. Do this:
- Open a terminal and check your default gateway:
ip route | grep default
On Windows:route printand look for0.0.0.0with a metric underGateway. - If the gateway is missing or wrong, renew your IP lease:
- Windows:
ipconfig /releasethenipconfig /renew. - macOS:
sudo ifconfig en0 downthensudo ifconfig en0 up(replace en0 with your interface name — runifconfigto find it). - Linux:
sudo dhclient -vorsudo dhcpcd, depending on your distro.
- Windows:
- After renewal, check again with
ip route— you should see something likedefault via 192.168.1.1 dev wlan0.
Step 4: Kill the VPN remnants
VPNs often leave behind custom DNS entries or route changes. Even after disconnecting, some stay. Restart your network adapter — it's faster than rebooting:
- Windows: Open Device Manager, expand Network adapters, right-click your Wi-Fi card, choose Disable, wait 5 seconds, then Enable.
- macOS: Turn Wi-Fi off and on in the menu bar.
- Linux:
sudo nmcli networking off && sudo nmcli networking on(if using NetworkManager).
Still failing? Check these
- Router captive portal: Some public Wi-Fi networks (airports, cafés) redirect all traffic to a login page. Open any browser — if you see a login page, you're not really connected. Try visiting
http://example.com(not HTTPS) to trigger the portal. - IPv6 issues: Some ISPs have broken IPv6. Temporarily disable IPv6 on your adapter (Windows: uncheck IPv6 in adapter properties). If the internet works, your ISP's IPv6 is the problem. Keep it off.
- Router overload: Too many devices on the same router can exhaust the DHCP pool. Reset the router by unplugging it for 30 seconds. This forces a fresh DHCP lease for everyone.
- Antivirus or firewall: Some security software (looking at you, Norton) injects their own DNS proxy. Temporarily disable the firewall component to test.
If none of this works, you're dealing with a hardware problem — likely a dying router or a loose Ethernet cable (yes, even on Wi-Fi, the router's WAN port matters). Replace the router or call your ISP to check the line.