sodcalculator

08 Everyday Math

Ubuntu Reset Network: Fix Connectivity Issues

Guide 08-68237 · Updated · Step by step

Resetting the network on Ubuntu is achieved by restarting the NetworkManager service or clearing the connection profiles stored in /etc/NetworkManager/system-connections/. This action forces the operating system to re-initialize its networking stack, re-authenticate with your router, and reload configuration files, which resolves most common connectivity failures.

Background: How Ubuntu Manages Connections

Unlike older Linux distributions that relied heavily on static text files in /etc/network/interfaces, modern Ubuntu versions (18.04 LTS and later) use NetworkManager as the primary daemon for handling network connections. This service manages both wired Ethernet and wireless Wi-Fi interfaces, ensuring that when you plug in a cable or join a Wi-Fi network, the appropriate drivers are loaded and IP addresses are assigned via DHCP.

Understanding this architecture is crucial because “resetting” the network does not mean wiping your hard drive or reinstalling the OS. It means forcing the software layer to forget current states and start fresh. This is particularly useful when:

  • Your computer shows “No Internet Access” despite being connected to Wi-Fi.
  • You recently changed router settings (SSID, password, or channel).
  • A previous script or manual configuration left a stale IP address or DNS entry.
  • Bluetooth tethering or mobile broadband adapters are not appearing in the menu.

The system stores connection profiles in two main locations: user-specific configurations in ~/.config/NetworkManager/ and system-wide profiles in /etc/NetworkManager/system-connections/. A reset typically targets the active state of the daemon rather than deleting these permanent profiles, though advanced users may choose to clear specific profiles if they are corrupted.

How It Works: The Restart Process

When you restart the NetworkManager service, the daemon performs a controlled shutdown and immediate startup sequence. During the shutdown phase, it disconnects all active interfaces, releases any leased IP addresses from the DHCP server, and stops monitoring interface changes. Upon restarting, it scans for available networks, reloads configuration files from disk, and attempts to reconnect using the saved credentials.

This process effectively clears temporary glitches such as:

  • DHCP lease expiration errors where the router refuses to renew an IP.
  • Stuck ARP (Address Resolution Protocol) caches that map MAC addresses to IPs incorrectly.
  • Driver hangs where the kernel module controlling the NIC (Network Interface Card) has stopped responding to commands.
  • DNS resolution failures caused by cached negative responses from upstream servers.

It is important to note that this method does not fix hardware failures. If your Wi-Fi card is physically damaged or the driver is incompatible with your current kernel version, a software reset will yield no results. However, for 90% of connectivity issues, this is the first and most effective troubleshooting step.

How to Choose the Right Method

There are several ways to reset networking on Ubuntu, ranging from a simple service restart to a complete profile purge. You should choose the method based on the severity of the issue and whether you want to preserve your saved Wi-Fi passwords.

  1. Service Restart (Recommended): Use this for general connectivity drops. It preserves all saved Wi-Fi passwords and VPN configurations while refreshing the connection state. This is the safest option for daily users.
  2. Interface Toggle: Use this if only one specific adapter (e.g., Wi-Fi but not Ethernet) is failing. Disabling and enabling just that interface avoids disrupting other active connections like Bluetooth or wired links.
  3. Profile Purge (Advanced): Use this only if you suspect a corrupted configuration file is preventing connection. This deletes saved Wi-Fi passwords and requires you to re-enter them manually. Do not use this unless simpler methods fail.

For most users, starting with the service restart is sufficient. If that fails, proceed to checking physical hardware and driver status before considering a profile purge.

Common Problems and Troubleshooting

Even after resetting the network, some users may still face issues. Below are common scenarios and their solutions.

Problem: “Disconnected” Status Persists
If the network icon shows a red cross or “Disconnected” even after a restart, check if the interface is physically up. Run ip link show in the terminal. If the interface (e.g., wlan0) shows “DOWN”, bring it up manually with sudo ip link set wlan0 up.

Problem: Can Connect to Wi-Fi but No Internet
This is often a DNS issue. After resetting the network, try flushing the DNS cache by restarting the systemd-resolved service using sudo systemctl restart systemd-resolved. Alternatively, manually set a public DNS like Google’s 8.8.8.8 in your connection settings.

Problem: Wi-Fi Adapter Not Detected
A reset cannot fix missing drivers. Check if the kernel recognizes the device with lspci -nn | grep -i network. If the device appears but doesn’t work, you may need to install proprietary firmware packages like firmware-b43-installer or linux-firmware-nonfree.

Problem: Static IP Configuration Lost
If you previously set a static IP address, ensure it is still configured correctly in the NetworkManager GUI or via Netplan. A service restart does not delete static configurations, but a profile purge might remove them if they were stored in the system-connections directory.

Safety and Best Practices

Resetting network settings is generally safe, but there are precautions to take.

  • Backup Configurations: Before purging profiles, copy /etc/NetworkManager/system-connections/ to a backup folder. These files contain encrypted Wi-Fi keys, and losing them means re-entering passwords for every network.
  • Root Access Required: Most reset commands require sudo privileges. Ensure you have administrative access to the system. If you are locked out of Wi-Fi, you may need to connect via Ethernet or USB tethering to run these commands.
  • Kernel Updates: Sometimes, a pending kernel update can cause network instability. If you recently updated Ubuntu, consider rebooting the entire system instead of just restarting the network service, as new kernel modules may need to be loaded.

Alternatives to Full Resets

If a full reset feels too drastic, try these lighter interventions first.

  • Forget and Rejoin: In the Wi-Fi settings, click “Forget” on the problematic network, then reconnect. This refreshes the authentication handshake without affecting other connections.
  • Reboot the Router: Often, the issue lies with the ISP modem or router, not the Ubuntu machine. Power cycling the router can resolve DHCP conflicts.
  • Check Airplane Mode: Ensure the global airplane mode switch is off. Sometimes toggling it off and on can reset all radio interfaces simultaneously.

Frequently Asked Questions

Will resetting the network delete my Wi-Fi password?

No, simply restarting the NetworkManager service does not delete saved passwords. Your Wi-Fi credentials are stored in keyring files and configuration profiles. Only if you manually delete the connection profile from the settings menu or purge the system-connections directory will you lose the saved password and need to re-enter it.

How do I reset network settings on Ubuntu 22.04 or 24.04?

The process is identical across recent LTS versions. Open a terminal and run sudo systemctl restart NetworkManager. For a more thorough reset, you can also restart the DNS resolver with sudo systemctl restart systemd-resolved. These commands work on GNOME, KDE, and other desktop environments.

Why does my internet work for a few minutes then stop?

This is often caused by a DHCP lease renewal failure or a power-saving feature turning off the Wi-Fi card. Check your power management settings in the terminal with iwconfig. If power save is enabled, disable it using sudo iwconfig wlan0 power off (replace wlan0 with your interface name). Also, ensure your router’s DHCP lease time is not set too short.

Can I reset network settings without using the terminal?

Yes, but it is less comprehensive. You can toggle Wi-Fi off and on from the system menu bar. For a deeper reset, you can go to Settings > Network, select your connection, click the gear icon, and choose “Forget Connection,” then reconnect. This achieves a similar result to forgetting the profile but is limited to single networks.

What if NetworkManager keeps crashing after a reset?

If the service crashes repeatedly, check the logs with journalctl -u NetworkManager -f. Look for errors related to specific drivers or conflicting services like ModemManager (which handles mobile broadband). You can temporarily disable ModemManager with sudo systemctl stop ModemManager to see if it resolves the conflict.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Everyday Math bed →