How to Stop Ubuntu from Automatically Disconnecting from Wi-Fi

The Aggressive Power Saving

Ubuntu Linux, especially when running on a laptop, employs aggressive power management strategies to extend battery life. One of the ways it does this is by putting the Wi-Fi adapter into a low-power “sleep” state if it detects periods of network inactivity, or if the laptop screen is turned off. While this saves a marginal amount of battery, it results in the system automatically disconnecting from your Wi-Fi network. If you are running a background SSH session, downloading a large file, or hosting a local development server, this sudden, silent disconnection will instantly kill your active tasks and require you to manually reconnect.

Disabling Wi-Fi Power Management

To ensure a stable, continuous internet connection and stop Ubuntu from automatically disconnecting your Wi-Fi adapter to save power, you must modify the NetworkManager configuration file.

You need to edit the configuration using the terminal with root privileges. Open a terminal (Ctrl+Alt+T). Type sudo nano /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf and press Enter (provide your password). The Nano text editor will open a very short file. You will see a line that reads wifi.powersave = 3. The number 3 tells the system to enable aggressive power saving. Use your arrow keys to navigate to the ‘3’, delete it, and change it to a 2. (The number 2 explicitly tells NetworkManager to disable Wi-Fi power management). The line should now read exactly: wifi.powersave = 2. Save the file by pressing Ctrl+O, hit Enter to confirm, and then exit Nano by pressing Ctrl+X. Finally, restart the NetworkManager service to apply the change immediately by typing sudo systemctl restart NetworkManager. Your Wi-Fi will now stay connected indefinitely.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.