I have an unstable WiFi connection, and the bandwidth frequently reaches 0 without actual disconnection (it is connected but without data transfer). Resetting the network manager by

sudo service network-manager restart

perfectly fixes the problem. However, I have two issues:

  1. How can I reset the network manager without a downtime? With the above command, any ongoing download will be interrupted. Is it possible to keep the current connection while resetting?
  2. How can I write a bash script to periodically check the network connection and reset it if there is no data transfer?

I use Ubuntu 20.04.


When you restart the network manager all connections are gone, so there is no way to avoid downtime. However, what you can do is to connect to a LAN, configure the LAN with iface. This would likely let you stay connected while you restart the network manager. If it does not, you can configure a static route to divert all traffic to LAN first.

Read about iface and how to configure /etc/network/interfaces here: NetworkConfiguration - Debian Wiki.

Read about routing traffic to specific network interface here: Route only specific intranet traffic via eth0; everything else via wlan0

Hope this helps.


The information/answers provided by others are correct, you cannot reset NM and persist a connection. You have to address the root cause of your problem.

I've found that many Wifi related issues can be resolved by disabling the power management.

Here's how I do it:

Create: /etc/network/if-up.d/wifi-powerman-off
Enable: chmod +x /etc/network/if-up.d/wifi-powerman-off

Replace interface name


WLAN_IFACE=<<interface name>>

if [ ! -x $IWCONFIG ]; then
    exit 1

if [ "$IFACE" = $WLAN_IFACE ]; then
    $IWCONFIG $IFACE power off

It is not possible, also if you destroy or put in down state an interface the connection are closed too.

Restart operation bring down your interfaces and then bring up again.

If the only fix you have figured out is reset the network interface you do not have method to reach your goal.

My suggestion to you is try to debug the connection and understood why this append, but restart the network without closing connection is not possible.


If it's already boken then you don't really have anything to lose and even then most devices will paise untill they have wifi again

EDIT: The downloads will pause until they are reconnected so they will just stop for a bit then resume as for the scrip I have no idea

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.