No internet after disconnecting or removing a VPN: how to get it back

A VPN changes the proxy, DNS, routes and firewall, and puts them back when it disconnects. After a crash or a careless removal some of it stays, and the internet doesn't work without the VPN either. The fastest fix is the program itself: start it (install it again if it's gone), connect, disconnect, turn off its kill switch and quit. Then restart the computer. If that isn't possible, find what is left: no site opens by IP means routes or firewall, names don't resolve means DNS, only the browser fails means a proxy. The commands below undo each.

Updated

Veli puts things back, and says when it can't. Veli sets no system proxy, so there is none to leave.

Download Veli for free
On this page

Try these first, in this order

  1. 1

    Let the VPN clean up after itself

    Start the program, connect and disconnect with its own button, then quit from the tray or the menu bar. If you removed it, install the same one again for a minute: this takes away what it set far more safely than you can by hand.

  2. 2

    Turn off its kill switch

    Some clients keep the internet closed on purpose after a drop, until you connect again or turn the protection off. Look for kill switch, “always require VPN”, “block internet without VPN”.

  3. 3

    Restart the computer

    Routes and adapters of a program that has died go away. Firewall rules, DNS and the proxy can stay.

  4. 4

    Check with another device

    If the phone has no internet on the same Wi-Fi either, it isn't the VPN: restart the router and look at the provider.

  5. 5

    Then find what is left

    Three commands in the next section tell the proxy from DNS and from the firewall.

What exactly is broken

Run these with the VPN off. The first goes to an address without names, the second asks for a name, the third goes the way a browser does.

Windows: PowerShell or cmd
ping -n 2 1.1.1.1
nslookup example.com
curl.exe -sI -m 8 https://example.com
macOS and Linux: Terminal
ping -c 2 1.1.1.1
nslookup example.com
curl -sI -m 8 https://example.com
  • The ping fails too: General failure, Destination host unreachable, or silence

    What is leftRoutes into a dead tunnel, or the kill switch's firewall rules

    What to doThe routes and firewall of your system below

  • The ping works, nslookup doesn't

    What is leftDNS of the VPN: an address that exists only in its tunnel

    What to doReturn DNS to automatic

  • Both work, curl works, the browser doesn't

    What is leftThe system proxy or the browser's own

    What to doTurn the proxy off

  • Both work, curl doesn't, 127.0.0.1 in its error

    What is leftProxy variables

    What to doRemove http_proxy, https_proxy, all_proxy

  • Some sites open, others don't

    What is leftIPv6 turned off halfway, a routing rule, or MTU

    What to doTurn the adapter off and on; on Windows reset the network

  • The Wi-Fi shows “No internet”, though sites open

    What is leftThe system's check is closed by a leftover rule or DNS

    What to doSame as the first two rows

  • It worked for years, then a driver or antivirus of the VPN was removed

    What is leftA filter driver in the adapter's settings

    What to doReset the network; on a Mac, remove the system extension

Windows: undo it

PowerShell as administrator. The adapter's name in quotes comes from Get-NetAdapter: on a Windows in another language it isn't Wi-Fi.

The proxy
Set-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -Name ProxyEnable -Value 0
netsh winhttp reset proxy

The first is the browsers' switch (the same one is in Settings → Network & internet → Proxy), the second is for services. Restart the browser. If your work gives you a proxy, don't touch either.

DNS
Get-DnsClientServerAddress -AddressFamily IPv4
Set-DnsClientServerAddress -InterfaceAlias 'Wi-Fi' -ResetServerAddresses
ipconfig /flushdns

An address such as 10.x or 172.x next to your Wi-Fi that isn't your router's is a leftover. The second line returns it to automatic.

DNS rules for names
Get-DnsClientNrptRule

Usually empty. A rule with Namespace . sends all names to one server: if it belongs to the removed VPN, take it away with Remove-DnsClientNrptRule -Name and its name in braces. On a work computer ask the admins first.

Routes
Get-NetRoute -DestinationPrefix '0.0.0.0/0','0.0.0.0/1','128.0.0.0/1' -ErrorAction SilentlyContinue | Format-Table InterfaceAlias, DestinationPrefix, NextHop
Remove-NetRoute -DestinationPrefix '0.0.0.0/1','128.0.0.0/1'

One line with 0.0.0.0/0 and your router's address is normal. The halves, 0.0.0.0/1 and 128.0.0.0/1, belong to a VPN: with no VPN on, the second line removes them and asks to confirm.

Firewall rules
Get-NetFirewallRule -Direction Outbound -Action Block -Enabled True | Format-Table DisplayName, Group

Blocking outbound rules are rare on a home computer, and the name or group says whose they are. Turn one off with Disable-NetFirewallRule -DisplayName and the name: that can be undone, unlike deleting.

The last resort
netsh winsock reset
netsh int ip reset

Then restart. The same, deeper, is Settings → Network & internet → Advanced network settings → Network reset: it reinstalls adapters and forgets Wi-Fi passwords, and other VPNs have to be installed again.

  • A leftover adapter — Device Manager → View → Show hidden devices → Network adapters: TAP, Wintun, WireGuard or the VPN's name. Remove the device if its program is gone.
  • A filter in the adapter — Network Connections (ncpa.cpl) → your adapter → Properties: an item with the name of the removed VPN or antivirus can be unticked.

macOS: undo it

The proxy
networksetup -setwebproxystate Wi-Fi off
networksetup -setsecurewebproxystate Wi-Fi off
networksetup -setsocksfirewallproxystate Wi-Fi off
networksetup -setautoproxystate Wi-Fi off

Names of other connections: networksetup -listallnetworkservices. The same is in System Settings → Network → Wi-Fi → Details → Proxies.

DNS
networksetup -getdnsservers Wi-Fi
sudo networksetup -setdnsservers Wi-Fi Empty
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

Empty returns DNS to automatic. An address in the first answer that you didn't set is a leftover.

Routes and the firewall
netstat -rn -f inet | grep -E 'default|^0/1|^128'
sudo pfctl -s rules
sudo pfctl -f /etc/pf.conf

0/1 and 128.0/1 on a utun adapter belong to a VPN and go away on restart. The second line shows firewall rules, the third loads the system's own set instead of them.

  • VPN profiles and filters — System Settings → VPN, and the filters in Network: turn off and remove what belonged to the VPN.
  • A device profile — System Settings → General → Device Management: a profile can hold DNS, a proxy or a VPN. Remove it if it isn't your employer's.

Linux: undo it

DNS
resolvectl status
cat /etc/resolv.conf
sudo systemctl restart systemd-resolved NetworkManager

A server from the tunnel next to your Wi-Fi is a leftover; restarting returns what the router gives. If /etc/resolv.conf doesn't change, look at lsattr /etc/resolv.conf: with an i some program locked it, and sudo chattr -i /etc/resolv.conf unlocks it.

Routes and rules
ip route
ip rule
ip link show type wireguard

In ip rule, three lines are normal: 0, 32766 and 32767. sudo wg-quick down wg0 takes down a WireGuard tunnel with everything it set.

Firewall and proxy
sudo nft list ruleset
sudo iptables -S OUTPUT
gsettings set org.gnome.system.proxy mode 'none'

A table or chain with the VPN's name that drops output is its kill switch. sudo nft delete table inet NAME removes one table: take the name from the first answer.

Android and iPhone

  • Android, Always-on VPN. Settings → Network & internet → VPN → the gear next to the app: with “Block connections without VPN” on, there is no internet until that VPN is up. Turn both switches off.
  • Android, Private DNS. Settings → Network & internet → Private DNS: a hostname the VPN needed may not answer now. Set Automatic.
  • Android, the Wi-Fi proxy. The network's settings → Proxy: None.
  • iPhone. Settings → General → VPN & Device Management: delete the VPN's configuration and profile. Settings → General → Transfer or Reset iPhone → Reset → Reset Network Settings is the last resort and forgets Wi-Fi passwords.

When it isn't the VPN

  • The router or the provider: a phone on the same Wi-Fi has no internet either.
  • The plan: the mobile data or the home tariff ran out while the VPN was on.
  • Another protection: an antivirus with its own firewall, or a second VPN that starts with the system.
  • Your address was blocked by one site: other sites open.

Sources

How we write and check

In Veli

Veli puts things back, and says when it can't

Veli sets no system proxy, so there is none to leave. When you press Disconnect or quit from the tray, it takes away its routes, DNS and firewall rules. If the app was killed with the kill switch on, the internet stays closed on purpose, and the next start connects or opens it. While it is still closed, Home says “The kill switch keeps the internet closed until you connect again.” with the button “Open the internet”. So the first thing to do after a crash is to start Veli again.

If you have already removed it, install it, start it once, quit and uninstall. On Linux removing the .deb package takes the kill switch's rules and the tunnel's DNS away by itself; on macOS Settings → Advanced → “System component” → “Remove” does the same. Diagnostics → Network shows DNS, internet access and the clock, with “Flush the DNS cache” next to a DNS that doesn't answer.

FAQ

Why doesn't my internet work after disconnecting the VPN?

The client didn't put back something it changed: DNS, the proxy, routes, or the kill switch's firewall rules. Start it again, connect and disconnect; if that doesn't help, undo them by hand.

Why is DNS not working after I uninstalled a VPN?

The adapter still has the VPN's DNS address, which nobody answers at now. Return DNS to automatic and flush the cache.

How do I remove VPN proxy settings on Windows?

Settings → Network & internet → Proxy: turn off “Use a proxy server” and the setup script. For services, run netsh winhttp reset proxy as administrator.

Will resetting the network help?

Usually yes, but it is the last step: it reinstalls all adapters, forgets Wi-Fi passwords, and other VPN programs have to be installed again.

The VPN app crashed and there is no internet. What do I do?

Start the app again: most likely its kill switch is holding the network. Turn the kill switch off in the app, or connect.

A VPN that puts everything back

Veli is a free client for Windows, macOS, Linux and Android. It sets no system proxy, undoes its changes on exit and opens the internet again after a crash.