The Dropped Connection
A highly frustrating issue on Ubuntu Linux, particularly on laptops, is the tendency for the Wi-Fi connection to randomly drop or disconnect entirely after a period of use. You might be downloading a large file or in the middle of an SSH session when the network suddenly vanishes. While this can sometimes be caused by faulty router hardware, in Ubuntu, it is almost always the result of aggressive Power Management settings. To save battery life, the Linux kernel intentionally puts the Wi-Fi adapter adapter to sleep when it thinks the network is idle, causing the connection to snap.
How to Disable Wi-Fi Power Management
To ensure a stable, uninterrupted internet connection, you must edit the core NetworkManager configuration file and instruct the system to never put the Wi-Fi card into a low-power state.
1. Open your terminal application (Ctrl+Alt+T).
2. You need to edit the NetworkManager configuration file with root privileges. Run the following command:
sudo nano /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf
3. The text editor will open a very short file. You will see a block of text that looks exactly like this:
[connection]
wifi.powersave = 3
4. The number 3 means power saving is enabled. Use your arrow keys to move the cursor and change the 3 to a 2.
wifi.powersave = 2
(Note: A value of 2 explicitly disables power saving. A value of 0 simply defers to default behavior, so 2 is the correct strict setting).
5. Save the file by pressing Ctrl+O, then Enter. Exit the nano editor by pressing Ctrl+X.
6. For the changes to take effect immediately without rebooting your computer, you must restart the NetworkManager service. Run the following command:
sudo systemctl restart NetworkManager
Your Wi-Fi adapter will briefly disconnect and reconnect. From this point forward, the Linux kernel will run the Wi-Fi card at full power 100% of the time, completely eliminating random disconnects caused by sleep states. This will have a negligible impact on overall battery life but vastly improve network reliability.