This became an interesting issue to me when I first came to know about it. When I started to use VPN service to connect to my business network I found out that the VPN service get disconnected immediately after closing the lid of my MacBook Pro. It was so frustrating to sign into the VPN Service again and re-connecting to business network and opening all other apps required to accomplish my task. I would think If there is a way to stop this crippling behavior and keep myself connected to the work all the time even when my MacBook is in sleep mode or the lid is closed. In this post, I will share with you some simple tricks to prevent your VPN connection drop after closing the lid of MacBook Pro or when the Mac goes to sleep.
A large number of Mac users have noticed that the issue occurs because their Mac will immediately disconnect from WiFi network when it goes to sleep mode. Which causes all the services dependent on internet to disrupt and eventually loses the VPN connection as well. But for me, after digging the information around Apple support communities and different other forums, I found that this option is controllable through system preferences on every Mac. There is an option called “Put hard disks to sleep when possible” under Energy Saver preferences. It turns most of the network services off to save power, when your Mac goes to sleep. You can prevent this from happening, simply by turning this feature off. And for some Macs, turning the Power Nap ON allows you to stay connected with VPN connections that use a certificate to authenticate, not the VPN connections that only use password to connect.
Prevent VPN Connection drops after closing the Lid of MacBook Pro
Just follow the below mentioned steps:
- Choose Apple menu and select system preferences.
- Click to open “Energy Saver”.
- Click the Battery tab, and uncheck “Put hard disks to sleep when possible” option.
Disable Put hard disks to sleep when possible option Desktop
- For some Mac Models check the box for “Enable Power Nap while on battery power” option.
Enable Power Nap while on battery power on MacBook Pro
- Now click the Power Adapter tab and do the same things as mentioned in step 4 and step 5.
- Also make sure “Wake for Network Access” option is checked.
- Now connect to your VPN network and close the lid of your MacBook Pro or leave your desktop to go for sleep. Once the system is in sleep mode or the lid is closed, try to open the lid and wake the system up and check if the VPN connection is still alive. I am sure this will work fine now.
Power Nap is a new feature introduced in newer Mac. It allows Mac computers with flash memory to perform a number of useful task even when the Mac is asleep. It can be enabled in both situation on battery and when plugged in. Here are few activities that your Mac can perform when power Nap is enabled and it is asleep.
- Check and download new Mails.
- Update Contacts, Calendar, Reminders, Notes and other documents stored in iCloud.
- Keep Find My Mac service active and update the location of your Mac so that it can be accessed and wiped out even when asleep.
- Keep the VPN and Software update services active as well.
- Run Time Machine backup.
Power Nap is not available on all Mac model. Here is the list of Macs that support Power Nap.
iMac (Late 2012 and later)
MacBook Pro (all models with Retina display)
MacBook (Early 2015 and later)
MacBook Air (Late 2010 and later) – Requires OS X Mountain Lion v10.8.2 and later
Mac mini (Late 2012 and later)
Mac Pro (Late 2013)
Also, as another option – a forceful workaround suggested by John, you can control the Network Interface behavior whether it should turn off or not on user logout. In order to do this, you will need to find out the short name of the network interface which is currently active. Here are the steps that you need to follow.
- Open Terminal app from /Applications/Utilities folder.
- Type command “ifconfig” and hit enter.
- Note down the name of interface having status as active. Interface name usually appears on the left and looks something similar to en0 or en1. In my case also it was en1. The “ifconfig” command will give an output something similar to what is written below.
en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
inet6 0000::000:0000:0000:0000%en1 prefixlen 64 scopeid 0x5
inet 10.0.1.16 netmask 0xffffff00 broadcast 10.0.1.255
media: autoselect <full-duplex>
4. Now type the following commands without quotes, to prevent the wireless card from shutting down in case of logout or sleep.
$ “cd /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources”
$ “sudo ./airport en1 prefs DisconnectOnLogout=NO”
That was all about the VPN connection issue where it used to get disconnected as soon as I would close the lid of my MacBook Pro. Un-checking “Put hard disks to sleep when possible” option actually fixed this issue for me. I hope yours will be fixed too. Just in case, it doesn’t work for you then feel free to ask any question using the comment section below.
If you like my content or it helped you fix your problem, please consider buying me a coffee. Thank you for your support!