Wi-Fi disconnects when I lock the mac

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


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:

  • Lock the screen differently, for instance with a 3rd party program (http://forums.whirlpool.net.au/archive/2000041, applies to Mac OS X 10.7.5) (I use hot corners for that).

  • Some claim that Apple WiFi equipment spares them from suffering this issue (maybe because an old, possibly incompatible base station was replaced?) (http://forums.macrumors.com/showpost.php?p=15380401&postcount=57 and http://forums.macrumors.com/showpost.php?p=15442704&postcount=63).

  • Add a new network location (http://osxdaily.com/2012/08/02/fix-os-x-mountain-lion-wireless-connection-problems/).

  • Change MTU size to prevent dropped connections (also http://osxdaily.com/2012/08/02/fix-os-x-mountain-lion-wireless-connection-problems/).

    (These two don't relate exactly to disconnects after locking but more generally to connectivity problems in "Mountain Lion".)

  • As a last resort, a clean install (restoring applications/settings from Time Machine) might help.

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...


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 )