94

Everytime I lock my mac and log back in two minutes, It has disconnected the wi-fi network. Is there a setting to disable this?

Model: Mac Book Pro - 15-inch, Mid 2010 I lock it by clicking 'Login Window...' after clicking my username on top right corner of the menu bar.

0

10 Answers 10

87

Do the following:

Find out what the network interface is for your wifi. Mine is "en1" for this example (I have obfuscated my MAC addresses with "00")

ifconfig
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
status: active

Then, you need to set up the airport util for your wireless card to tell it not to shut off:

cd /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources
sudo ./airport en1 prefs DisconnectOnLogout=NO
17
  • 1
    I really don't know why this isn't the accepted answer, this was exactly the problem I was having. Thanks!
    – NateDSaint
    Oct 10, 2013 at 15:35
  • 11
    This didn't work on my 2013 MBPr, unfortunately.
    – gWaldo
    May 8, 2014 at 18:38
  • 2
    Didn't work on late 2013 MBPr.
    – Johann
    Jul 21, 2014 at 18:32
  • 4
    what if it's not a wireless card? (ethernet via thunderbolt). What would be the path?
    – nute
    Mar 8, 2015 at 15:02
  • 5
    (for followers, command control power is "reboot" so don't do that. If you don't have an eject button, "lock screen" shortcut is ctrl+shift+power)
    – rogerdpack
    Oct 22, 2015 at 18:30
20

EDIT: Please see John's answer above, which basically says to open Terminal and run:

cd /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources
sudo ./airport en1 prefs DisconnectOnLogout=NO

where en1 is the name of your Mac's WiFi interface. You can get it with this Terminal command:

ifconfig | grep -B 6 'status: active' | head -n 1 | cut -d : -f 1

when WiFi is the only active interface (that is, no Ethernet cable attached).

To list the interface settings, run in Terminal:

./airport en1 prefs

Typical output is:

AirPort preferences for en1:

DisconnectOnLogout=NO
Unable to retrieve JoinMode
JoinModeFallback=DoNothing
RememberRecentNetworks=YES
RequireAdminIBSS=NO
RequireAdminNetworkChange=NO
RequireAdminPowerToggle=NO
WoWEnabled=YES

Other people's Macs are misbehaving in a similar way, read for example this and this. Although I own a similar MacBook Pro that runs 10.8.2 I can count myself fortunate not to suffer this issue.

Consequently the list below is rather a compilation of possible fixes (some may even seem absurd or just plain obvious) than tested recommendations:

I checked the power management settings (command pmset) and defaults but couldn't find anything.

(My setup is: clean "Mountain Lion" install (with restore from Time Machine) and Airport Express base station.)

Hope this will help...

2
  • One comment, most third party programs only lock the main screen - if you have a second monitor, or someone can attach one, they're useless.
    – John Smith
    Feb 22, 2017 at 5:32
  • Changing the preferences via airport in the terminal did not resolve this issue for my High Sierra 10.13.2 MacBook Pro.
    – Cory Klein
    Jan 24, 2018 at 19:29
6

Try the workaround here: http://forums.whirlpool.net.au/archive/2000041

The problem with OS X is to "lock" your screen you have two options, either let the screen saver time out and lock your screen (which doesn't disconnect WIFI) or clicking on your "user name" on the top right corner and choosing "Login Window" which essentially locks your mac and takes you to a login window, however this approach disconnects the WIFI Connection.

The work around I have found is installing an app called "Lock Me Now" from the app store and once it has been installed launch it and from the preferences "check" "Just Lock" under "Lock Type" which does the same thing as the screen saver timing out. Also for ease of use you can assign a keyboard shortcut to simplify the process of locking your Mac (I chose to use Command + L )

2
  • I realized that my initial problem was actually resolved by this, but the workaround I had built worked better with @John's answer. I'm going back to yours, though, as it makes it easier to lock my desktop and walk away without worrying about everything turning off while I'm gone. : ) Thanks!
    – NateDSaint
    Oct 14, 2013 at 21:22
  • The problem is, this is a security risk, as it displays your username publicly when you wake it, even if you have your login window set not to.
    – John Smith
    Feb 22, 2017 at 5:34
3

Open Applications > Utilities > Keychain Access then go to Keychain Access in the menu bar on the top, then Preferences - click "show keychain status in the menu bar".

You will see a little lock on the menu bar ... click on it then lock screen from there.

2
  • 1
    I use this all the time, and I still get disconnected from my network.
    – nute
    Mar 8, 2015 at 15:05
  • 1
    This preference option is not present on my MacBook Pro running High Sierra 10.13.12.
    – Cory Klein
    Jan 24, 2018 at 19:26
3

You can do it by writing simple service for Mac, this is best solution for this problem.

Try this out -http://tecride.blogspot.in/2015/04/wifi-disconnects-when-you-lock-osx.html

5
  • 4
    While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes.
    – Tetsujin
    Apr 9, 2015 at 13:58
  • 1
    This is the only answer that actually works without requiring the user to completely change his/her workflow.
    – Mashmagar
    Dec 8, 2015 at 17:38
  • This is the best answer for me (2015 MBP, OS 10.11), though I'm disappointed that I need to learn a new lock shortcut. Jan 21, 2016 at 18:21
  • As I commented above, this will show your username to anyone trying to unlock your Mac, even if you have your login window set not to. That's a security risk.
    – John Smith
    Feb 22, 2017 at 5:34
  • 2
    the article is no longer available, that's why it would have been better to paste the solution directly here
    – fabb
    Aug 26, 2020 at 10:05
3

You can live without "lock me now" app.

just use:

CONTROL + SHIFT + 'key to eject cd' (or if you don't have an eject key, control+shift+power)

5
  • what do you mean by "lock me now"?
    – dwightk
    Mar 13, 2014 at 21:15
  • Pretty sure he means the above mentioned program in the app store. His suggestion does the same thing without having to have an app. Apr 8, 2014 at 18:43
  • 4
    Unfortunately this method also drops the network on MBPr's
    – gWaldo
    May 8, 2014 at 18:38
  • @gWaldo, Really? High Sierra?
    – Pacerier
    Jan 10, 2020 at 6:53
  • @Pacerier No, whatever was current in 2014... When I posted that comment.
    – gWaldo
    Jan 13, 2020 at 15:48
0

For OS X 10.9, instead of locking your Mac consider using the following command in terminal:

open -a /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app

The command starts the ScreenSaveEngine.app which locks the screen without disconnecting the Wi-Fi. I am not sure if it works on other versions of OS X.

0

Solution for dummies like me

To find your WiFi interface you can open up a terminal and run this following command. In macOS Big Sur WiFi interface it is named en0
➜  ~ ifconfig
Now move into airport utility folder
➜  ~ cd /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/
List the preferences for WiFi interface. In my case en0
➜  ~ ./airport en0 prefs
Finally to do not let WiFi disconnecting on logout, change the related preference to NO
➜  ~ ./airport en0 prefs DisconnectOnLogout=NO
-2

For maverick users-

To enabled the "Open Wireless Diagnostics.." as it doesn't show up by default to diagnose the WIFI connection.

Click the wifi icon on the menu bar with the Option key pressed. On the bottom of the list, you have "Open Wireless Diagnostics..."

-2

found a solution for this problem. Seems pretty well documented

http://osxdaily.com/2014/04/24/fix-mac-disconnect-wifi-sleep/

4
  • 1
    Welcome to Ask Different! While this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – Glorfindel
    May 14, 2018 at 7:08
  • Links tend to die over time. If [when] that happens your answer will not be very helpful. Please provide the salient points from the link in your answer. Also, how does your answer differ from the nine answers already posted, including the accepted answer? May 14, 2018 at 9:42
  • In accepted answer, 1. many comments are there and they told - 'Didn't work on late 2013 MBPr.', So, I didn't try accepted answer 2. I was searching a GUI solution not CLI solution So, this is different solution from another one
    – Arpit
    May 14, 2018 at 12:58
  • yes, I know stackoverflow rules but in this link, they showed via images and it was difficult to write everything in words. So, I shared link only.
    – Arpit
    May 14, 2018 at 13:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .