This question already has an answer here:

My wifi is not working after suspend on 15.04. I can click my way to success on the wifi icon in the menu bar (and the enable wifi option), but I want to use scripts to automate the procedure. Here is my attempt

1) create executable bash script /etc/pm/sleep.d/10_resume_wifi with the contents

#!/bin/sh
  case "$1" in
   hibernate|suspend) ;;
   thaw|resume)
      nmcli r wifi off && nmcli r wifi on ;;
esac

2) create executable file /etc/system.d/system/wifi-resume.service with contents

[Unit]
Description=Restart wifi after waking up
After=suspend.target

[Service]
Type=simple
ExecStart=-/etc/pm/sleep.d/10_resume_wifi

[Install]
WantedBy=suspend.target

and run sudo systemctl enable wifi-resume.service

This is not working, and I get the following lines from dmesg after resuming from suspend

[11168.786104] cfg80211: World regulatory domain updated:
[11168.786111] cfg80211:  DFS Master region: unset
[11168.786113] cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)
[11168.786119] cfg80211:   (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[11168.786124] cfg80211:   (2457000 KHz - 2482000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[11168.786128] cfg80211:   (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 2000 mBm), (N/A)
[11168.786133] cfg80211:   (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[11168.786137] cfg80211:   (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[11168.968257] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[11169.004818] ata3: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
[11169.006600] ata3.00: ACPI cmd ef/10:03:00:00:00:a0 (SET FEATURES) filtered out
[11169.009053] ata3.00: ACPI cmd ef/10:03:00:00:00:a0 (SET FEATURES) filtered out
[11169.009061] ata3.00: configured for UDMA/100
[11169.200846] firewire_core 0000:04:00.0: rediscovered device fw0
[11171.088442] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[11171.089310] ata1.00: ACPI cmd ef/10:03:00:00:00:a0 (SET FEATURES) filtered out
[11171.090296] ata1.00: ACPI cmd ef/10:03:00:00:00:a0 (SET FEATURES) filtered out
[11171.090469] ata1.00: configured for UDMA/100
[11171.615861] ERROR @wl_cfg80211_scan : WLC_SCAN error (-22)

After clicking my way to wifi, I get slightly different output from dmesg

[11331.635796] cfg80211: Calling CRDA for country: US
[11331.639456] cfg80211: Regulatory domain changed to country: US
[11331.639465] cfg80211:  DFS Master region: FCC

Any suggestions for why the script-based approach is not working? I am new at this, so there are likely several errors. Thanks in advance!

marked as duplicate by Eric Carvalho, David Foerster, Charles Green, Evandro Silva, Galgalesh Jan 22 '16 at 10:48

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • This worked for me: sudo service network-manager restart – hmjha Jul 25 '16 at 19:26

After a little more digging, I found a single script (posted here) that connects my computer to wifi after suspend. In short, I created the executable script /etc/systemd/system/wifi-resume.service with the following contents:

[Unit]
Description=Local system resume actions
After=suspend.target

[Service]
Type=oneshot
ExecStart=/bin/systemctl restart network-manager.service

[Install]
WantedBy=suspend.target

and ran the command sudo systemctl enable wifi-resume.service

Many thanks to Sean for solution.

  • Man, you saved my day! Worked like a charm on 15.10 too (if you want to edit your answer to add this info). Just got a Dell Precision M3800 (it has a Intel 7260 wifi) and after resume from suspend, wifi was always disconnected. Thank you! – Rael Gugelmin Cunha Nov 21 '15 at 10:24
  • Worked for me as well on Ubuntu 15.10 – AlexandruSerban Dec 24 '15 at 18:57
  • This worked for me on 16.04, thanks! – Prototype700 May 6 '16 at 19:08
  • worked perfect! – Christian Bongiorno May 15 '16 at 4:10
  • Awesome, I'm starting to love systemd more and more – Kris May 18 '16 at 19:01

Solution what works fine for me:

sudo touch /etc/pm/sleep.d/10_restart_network_manager
sudo chmod +x /etc/pm/sleep.d/10_restart_network_manager
sudo gedit /etc/pm/sleep.d/10_restart_network_manager

Paste this code inside the file:

#!/bin/sh

case $1 in
    resume|thaw)
        sudo /bin/systemctl restart network-manager.service
    ;;
esac
  • The systemctl was necessary for me as well running 15.10 on MBP 11,1. My wireless interface doesn't show the available networks without doing this restart. nmcli off/on does not seem to work in this instance. – Anthony Dec 14 '15 at 20:52
  • Worked for my x1 carbon 2015 on ubuntu 16.04. Thank you! – Joakim Koed Apr 21 '16 at 18:51

After many attempts at this annoying problem I came up with this solution. Create an executable file under /etc/pm/sleep.d/, and name it i.e. 10_resume_wifi, like this:

sudo touch /etc/pm/sleep.d/10_resume_wifi
sudo chmod +x /etc/pm/sleep.d/10_resume_wifi
sudo gedit /etc/pm/sleep.d/10_resume_wifi

Paste this code inside the file:

#!/bin/sh

case $1 in
     suspend|suspend_hybrid|hibernate)
        sudo nmcli n off
        ;;
     resume|thaw)
        sudo nmcli n on
        ;;
esac

Save and close the file, that's it.

This was the only solution that worked all the time. Note: Other solutions that I found used an older version of nmcli.

  • Worked for me on hp640g1 thanks – Jan Míšek Oct 14 '15 at 21:39

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