This particular version of the "doesn't work after suspend" came after upgrading to 16.04. It seems that the upgrade includes a Wicd applet (added to Metacity Classic Gnome task bar alongside regular network icon), but doesn't seem to work after a suspend. A sudo service network-manager restart
duplicates this problem. It takes a complete reboot to get Wifi going again. Any ideas why?
-
6Did you file a bug at launchpad for the problem ???– aposMay 16, 2016 at 14:04
-
3bugs.launchpad.net/ubuntu/+source/wpasupplicant/+bug/1556357– Alberto Salvia NovellaJun 20, 2016 at 17:36
-
Looks like this problem has been around since Ubuntu 14.– Dan DascalescuSep 9, 2016 at 3:41
-
This never happened under 14.04 LTS for me. The upgrade to 16.04 LTS is so great I'll keep it, but it keeps forgetting my WiFi password. The service is clearly running; just that it forgets the password and doesn't connect. I posted this: askubuntu.com/questions/934958/… - and I do not want to deal with blacklisting or anything strange.– SDsolarJul 11, 2017 at 3:57
-
... And the problem is still there in Ubuntu 20. I'm kinda fed up at this point.– Dan DascalescuJun 19, 2020 at 19:39
12 Answers
16.04 runs on systemd. Try the following:
sudo systemctl restart network-manager.service
If this works, you can create a script to automate it.
Open a terminal and type the following:
sudo nano /etc/systemd/system/wifi-resume.service
Now paste the script in there with a right click. Exit with CTRL + X and press Y to save. Now to activate it: sudo systemctl enable wifi-resume.service
Script:
#/etc/systemd/system/wifi-resume.service
#sudo systemctl enable wifi-resume.service
[Unit]
Description=Restart networkmanager at resume
After=suspend.target
After=hibernate.target
After=hybrid-sleep.target
[Service]
Type=oneshot
ExecStart=/bin/systemctl restart network-manager.service
[Install]
WantedBy=suspend.target
WantedBy=hibernate.target
WantedBy=hybrid-sleep.target
Hope this helps. It works on my laptop.
-
2
-
6I would say don't bother reinstalling for this. I did a clean install and I'm running into this issue on 16.04. Never had a problem with 14.04. May 4, 2016 at 0:25
-
3
-
1@mikeymop I have been thinking this as well. I know some parts of the system is still using upstart, so that might trigger something. Since 16.10 is full systemd and does not have the error, you might be correct. Sep 2, 2016 at 9:19
-
1
@147pm Did you ever get this working?
I found I had a quite similar problem, though I am on Kubuntu 16.10 (KDE-based, not Gnome), and with an HP ProBook laptop. And, unlike yourself, it wasn't my Wifi which died after suspend/wakeup, but my ethernet port. Still, I wonder if they are related.
I also do see that you do not have the problem under KDE. But I would be interested to know if the solution below does help under Gnome, as the solution is not based upon window manager, desktop environment or applets.
First, just to confirm that restarting the network manager service..
$ sudo systemctl restart network-manager.service
did not work for me.
However, I did find an answer that worked, thanks to buzhidao's question and info at can't connect to internet after suspend and GAD3R's comment there.
Using their info, I found that first researching which ethernet hardware and driver/module I am running, and then removing and reloading that module, did work for me (though it did not for buzhidao):
Wifi:
$ lspci -knn | grep Net -A2
Ethernet:
$ lspci -knn | grep Ether -A2
The second of these (ethernet) was what I used, and I found:
03:00.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [10ec:8168] (rev 0c)
Subsystem: Hewlett-Packard Company RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller [103c:1944]
Kernel driver in use: r8169
Kernel modules: r8169
so i reloaded the 'r8169' driver:
$ sudo rmmod r8169 && sudo modprobe r8169
and voila! This worked. My ethernet port / connection came back alive (after suspend/wakeup) without having to reboot.
(I also did NOT have a Realtek wifi device, but a Qualcomm Atheros (mod: ath9k) which perhaps explains why wifi continued to work for me after wake-from-suspend.)
As you can see from my comment on that other post, I wondered whether the problem is the common element between Buzhidao and myself: Realtek Semiconductor devices. Even though they use different modules, they might share some common code? Or even be treated differently by the newer kernel code now in some way?
Do you yourself have a Realtek-based wifi device? (using lspci above)? Do you have any luck re-installing the module (rmmod/modprobe above)?
Anyway, just a shot in the dark. If you have found an eventual answer for yourself, please let us know! Thx.
-
1I also have a RTL8111/8168/8411 ethernet and
sudo rmmod r8169 && sudo modprobe r8169
solved the problem.– lenoohJun 24, 2018 at 13:25 -
Same issue on Debian 9 with KDE. Reinstalling as above fixed it. Thanks a ton.– sumitkmAug 2, 2018 at 6:16
-
My computer* too has a RTL8111/8168/8411 ethernet device and
sudo rmmod r8169 && sudo modprobe r81691
finally fixed the issue for me. Didn't have this problem before kernel version 4.16. (*Debian 10 with GNOME, Kernel 4.16, and proprietary firmware from Realtek)– ossbuntuAug 8, 2018 at 12:54 -
worked for me archlinux with ath10k_pci– user690429Jul 6, 2019 at 11:49
-
re-insert kern module fixed for me on xub 19.10. Interestingly, this issue started only recently, didn't happen on 19.04 or older for me. I'm on t420. Apr 5, 2020 at 10:02
To auto-restart NetworkManager after resume in an environment without sudo
access, create a script in /etc/pm/sleep.d
(any name), set the executable bit via chmod +x
, and insert the following content:
case "${1}" in
resume|thaw)
# systemctl restart network-manager.service
service NetworkManager restart
;;
esac
For me, the service
line worked, but systemctl
may work better for you.
Source: https://askubuntu.com/a/92235/30266.
-
2The
service NetworkManager restart
worked for me, but the placement of the script did not (on 16.04). I had to move the script to/lib/systemd/system-sleep/script-name-here
. In this case the first argument to the script is[pre | post]
, so I had to change the case statement tocase "${1}" in ... post) ...
. I also wrapped the inner statement incase "${2}" in ... suspend) ...
.– ChesterNov 16, 2016 at 13:28 -
1
For me it seems to be random, but sometimes the wifi just disconnects if I'm connected, or doesn't show networks if I'm not. Sometimes putting my laptop into sleep mode seems to trigger it, but not always.
Some combination of these usually gets it going again without rebooting:
sudo iwlist $(ifconfig | grep -Po '^w\w+') scan
sudo service network-manager stop; sleep 5; sudo service network-manager start
- Simply calling
restart
here never seems to work for me. It looks like it tries to start it up before it's finished shutting it down, hence I have more luck pausing betweenstop
andstart
.
- Simply calling
- Turn off wifi in UI; wait a few seconds; turn it back on
None of those seems to consistently work, but I listed them in order of most-likely-to-succeed first.
-
1Also for me
restart
didn't work butstop
andstart
did! No other answer worked. Thanks a lot! Sep 30, 2020 at 9:46
Working method on Ubuntu 16.04:
Create the service: sudo nano /lib/systemd/system/wifi-resume.service
The service is calling the program from:
/etc/init.d/network-manager
Paste the code:
#/lib/systemd/system/wifi-resume.service
#sudo systemctl enable wifi-resume.service
[Unit]
Description=Restart network-manager at resume
After=suspend.target
After=hibernate.target
After=hybrid-sleep.target
[Service]
Type=oneshot
ExecStart=/bin/systemctl restart network-manager
[Install]
WantedBy=suspend.target
WantedBy=hibernate.target
WantedBy=hybrid-sleep.target
Then enable the service:
sudo systemctl enable /lib/systemd/system/wifi-resume.service
This creates the symlinks into the indicated [Install] directories of /etc/systemd/system and activates the service
Afterwards you can check the status with: systemctl status wifi-resume.service
Run these commands one by one in the terminal.
1.sudo nano /lib/systemd/system-sleep/wififix
2. Paste the below code and save it.
#!/bin/sh
set -e
if [ "$2" = "suspend" ] || [ "$2" = "hybrid-sleep" ]; then
case "$1" in
pre) true ;;
post) sleep 1 && service network-manager restart ;;
esac
fi
sudo chmod +x /lib/systemd/system-sleep/wififix
Tested on Ubuntu 20.04. It works on other Mint and Elementary versions as well.
I got the solution from here.
I had the same problem with bluetooth: After suspend my bluetooth mouse did not work. So I derived the solution from above:
sudo nano /etc/systemd/system/bluetooth-resume.service
enabled the new service
sudo systemctl enable bluetooth-resume.service
and edited the service
#/etc/systemd/system/bluetooth-resume.service
#sudo systemctl enable bluetooth-resume.service
[Unit]
Description=Restart bluethooth at resume
After=suspend.target
After=hibernate.target
After=hybrid-sleep.target
[Service]
Type=oneshot
ExecStart=/bin/systemctl restart bluetooth.service
[Install]
WantedBy=suspend.target
WantedBy=hibernate.target
WantedBy=hybrid-sleep.target
I also tried to edit ...
sudo nano /etc/bluetooth/main.conf
and changed
AutoEnable=true
BUT this did NOT work for the "resume problem" and had no inmpact on new bluetooth devices anyhow!
I had the same issue on my laptop Dell Inspiron 15R with Ubuntu 16.04. For me worked the script reported on the second reply.
After having installed the script I tried the suspension with the command in the upper right menu and even closing the lip, solving the problem.
I have to say that the problem was alternating in its behaviour (that is, sometimes it worked before installing the script).
I had the same issue connecting back to my home wifi after suspend. Tried the various other suggested answers which would occasionally work but not always.
Eventually the following fix allowed for consistently connecting to the wifi:
1) Edit this file:
sudo vim /etc/NetworkManager/NetworkManager.conf
2) By adding this to it:
[device]
wifi.scan-rand-mac-address=no
Now probably simple
sudo apt update
sudo apt upgrade
should work.
In my case among upgraded packages there was bcmwl-kernel-source (6.30.223.271+bdcom-0ubuntu1~1.3)
and after this update wifi works again.
I had the same problem on Ubuntu 20.04. I tried the solutions above which didn't work for my intel 6235 adapter.
Random websearches instead led me to the solution:
sudo modprobe -r iwlwifi
sudo modprobe iwlwifi
sudo systemctl restart NetworkManager
Which resolves the problem until next suspend.