Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Keep attempting reconnection to wireless network Network
Having trouble automatically reconnecting your unattended Mac to a wireless network because of unreliable signal quality? If you would like to have it keep reattempting reconnection until it manages to connect it's fairly simple to setup.

You need to use the airport command line tool in the Terminal. Open a terminal and run the following command (with no line breaks), typing in your password when prompted:
sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport prefs joinmode=automatic joinmodefallback=keeplooking
Unlike the JoinModeFallback setting of 'prompt' (which can be set in System Preferences) or 'donothing,' if it fails to join a network it will wait about a minute and then scan for a network to join again. It will do this until it succeeds. Very useful for an unattended Mac acting as a server, especially if you're not in the same location as it.

Note that this may have a negative affect on your battery life if running on a laptop.

[crarko adds: I haven't tested this one. I didn't have any unreliable wireless connection handy so I don't need the repeated attempts to join.

Here are the other options for the listed preference settings:

JoinMode (String)
  • Automatic
  • Preferred
  • Ranked
  • Recent
  • Strongest

JoinModeFallback (String)
  • Prompt
  • JoinOpen
  • KeepLooking
  • DoNothing
I believe JoinMode = Ranked and JoinModeFallback = Prompt are the defaults, if you want to switch back. If you type in the above command with just prefs and no other parameters it will tell you what the curent settings are. You might want to record those before making any changes.]
  • Currently 3.67 / 5
  You rated: 5 / 5 (6 votes cast)

Keep attempting reconnection to wireless network | 4 comments | Create New Account
Click here to return to the 'Keep attempting reconnection to wireless network' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Keep attempting reconnection to wireless network
Authored by: mkhaw on Feb 24, '11 08:55:05AM

You can type sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport help to get a pretty complete explanation of what the command can accomplish.

If you expect to use it with some frequency, create an alias for it. If your shell is bash, you can put into your ~/.bashrc file: alias airport="sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport"

[ Reply to This | # ]
Keep attempting reconnection to wireless network
Authored by: joostjodel on Feb 24, '11 02:41:52PM

Thanks for this command.
To make it make useful for my purposes, that is, trying to reconnect an old Powerbook server that regularly loses its WiFi connection, I cobbled together a few extras:

1. a bash script that can be invoked to check if Airport is still up

## simple script to check whether Airport is still up, and restart it in case it is down.
if ping -W2 -c4
then echo "Hurrah, still up in the air…"
sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport prefs joinmode=automatic joinmodefallback=keeplooking

This pings to your router (mine is on - change if appropriate) and runs the command if no network is up.

I placed this as "" in /usr/local/bin/ (don't forget to run a $chmod 770)

2. run the command visudo and add a few lines under:

# Cmnd alias specification
Cmnd_Alias AIRPORT = /usr/local/bin/

and under:

# User privilege specification
<your usename here> ALL=AIRPORT

3. make a launchd script "local.airport_up_check.plist" with the following content and place it in /Library/LaunchAgents:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "">
<plist version="1.0">
<true />

600 means run every 10 minutes (10*60 secs).

then run the command:
$ launchctl load /Library/LaunchAgents/local.airport_up_check.plist

[ Reply to This | # ]
Keep attempting reconnection to wireless network
Authored by: masterninja01 on Feb 25, '11 04:13:17AM

What if your airport never picks up your preferred network? This is problem I've been having for a long time now. I've tried everything under the sun… to my limited knowledge. It has a hidden SSID and I have to join the network by typing in the name like I'm joining another network, until it says for me to see the admin for support. Well, I then go to my available networks for my airport , and now the network shows up. All I have to do then is connect to it since my password is stored in my keychain.

Nice command though…

[ Reply to This | # ]
Keep attempting reconnection to wireless network
Authored by: phobaphobic on Mar 08, '11 08:43:15PM

Does anyone know a method to do this for a Bluetooth/PAN network?

[ Reply to This | # ]