VPN Connection drops after closing the Lid of MacBook Pro

0

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:

  1. Choose Apple menu and select system preferences.
  2. Click to open “Energy Saver”.
  3. Click the Battery tab, and uncheck “Put hard disks to sleep when possible” option.
    VPN Connection drops after closing the Lid of MacBook Pro
    Disable Put hard disks to sleep when possible option Desktop
  4. 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
    Enable Power Nap while on battery power on MacBook Pro
  5. Now click the Power Adapter tab and do the same things as mentioned in step 4 and step 5.
  6. Also make sure “Wake for Network Access” option is checked.
  7. 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

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.

Important Note:- 

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 the above method to prevent VPN Connection drops after closing the Lid of Mac will not be applicable in the cases where Mac is asleep for a long time. When you leave your Mac idle for a long time, it enters into a kind of deep sleep mode known as Safe Sleep or Standby Mode. It helps Mac conserve even more energy by turning off the power to some hardware parts such as RAM and USB buses.

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.

  1. Open Terminal app from /Applications/Utilities folder.
  2. Type command “ifconfig” and hit enter.
  3. 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

ether 00:00:00:00:00:00
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>
status: active

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.

LEAVE A REPLY

Please enter your comment!
Please enter your name here