Why Do My VPN Connections Disconnect On Sleep?
All modern computers include "sleep" functionality (often called "hibernation" on Windows). Rather than having to completely shut-down the computer to save power when not in use, sleep offers an alternative that puts the computer in a low power state instead.
While sleeping a computer draws a small amount of power to keep its memory state (RAM) active, while cutting power to the processor, storage, network interfaces, etc. This allows it to consume very little power while not in use, but almost instantly boot back up and pick up where it was last left before sleep.
As the processor and network interfaces are all turned off, it is not possible to keep a VPN connection active. Therefore Viscosity will gracefully disconnect your VPN connections just before your computer sleeps, and reconnect them when it wakes up. This prevents scenarios where the VPN connection on your computer may think it's active, but the VPN server has terminated the connection due to inactivity, which results in a non-functional VPN connection.
Answers to further common sleep-related questions can be found below.
Sleep and Standby Frequently Asked Questions
Can other applications use the network while the computer is sleeping?
No. When your computer is sleeping it is effectively off. Applications are not executed, and network interfaces like Ethernet and Wi-Fi are turned off. No network connectivity is possible.
The one slight exception to this is macOS's Power Nap and Windows Modern Standby features. When these features are enabled your computer will wake up periodically so it can check for email, sync with iCloud and OneDrive, and perform a few other limited activities. If this concerns you Power Nap can be disabled by going to System Preferences->Energy Saver and unticking the "Enable Power Nap" checkbox if it is ticked.
On Windows, if Modern Standby is detected, Viscosity will keep your connection alive as long as possible while in Modern Standby. This prevents network leaks in most cases. If this concerns you, Modern Standby's Network Connectivity can be disabled by going to Power & Sleep Settings, and setting the 'disconnect from the network' option under Network connection to Always.
Why do my VPN connections disconnect when my screen turns off?
Modern versions of macOS automatically sleep your computer when the display turns off. As the computer goes to sleep, any active VPN connection will be disconnected. By default your display will turn off after several minutes of inactivity.
You can disable this behaviour by going to System Preferences->Energy Saver and tick the "Preventing computer from sleeping automatically when the display is off". Please check for this option under both the Battery and Power Adapter tabs. The time until the display turns off can also be adjusted in this section.
On Windows, screen and sleep settings are separate but may be set to the same interval. You can change this by going to Power & Sleep Settings, and changing the timers for when your screen turns off or when your PC sleeps.
Why do my VPN connections disconnect when I lock my screen?
If your VPN connection/s disconnect when using macOS's "Lock Screen" option, or when opening Fast User Switching's Login Window, then it's likely due to one of two reasons:
1. Your computer is sleeping shortly after locking the screen, causing the VPN connection to become disconnected. By default recent versions of macOS will put your computer to sleep a few minutes after locking the screen. To disable this behaviour please see this article.
2. Your computer is connected via Wi-Fi and the Wi-Fi network interface is turning off. In some instances this has also been reported to occur when the screensaver is active. This is not the default behaviour of macOS, however this article details how to stop Wi-Fi from disconnecting when locking the computer or displaying the login window if it is occurring.
Why do my VPN connections disconnect when I'm away from the computer?
If you're finding your VPN connections are disconnecting while away from the computer for at least a short period of time, your computer is likely configured to go to sleep after a short period of inactivity (no mouse or keyboard use). You can check these settings by going to System Preferences->Energy Saver on macOS, or Power & Sleep Settings on Windows, and checking the selected time.
Viscosity also includes its own feature to disconnect VPN connections when the computer is idle. This can be configured under Preferences->General. This feature is off by default, however if it has been enabled it can be turned back off by unticking the "Disconnect connections after x minutes of inactivity" option.