Skip to content

Instantly share code, notes, and snippets.

@eduwass
Last active June 11, 2024 10:46
Show Gist options
  • Save eduwass/5b7b93248d8975d826792adce2d71d31 to your computer and use it in GitHub Desktop.
Save eduwass/5b7b93248d8975d826792adce2d71d31 to your computer and use it in GitHub Desktop.
force 5g wifi on mac

Force 5 GHz WiFi Connection on macOS

If you're experiencing issues with your Mac connecting to the slower 2G band on routers that share SSID between 5G/2G (like the Google Wifi Nest), here's a guide to help you force a 5 GHz connection.

Identifying the 5G Channel

  1. Check Current Band: Hold option and click on the wifi icon on the macOS status bar. This will display the band you are currently connected to.
  2. Scan WiFi Channels: Use the following command to list all channels your WiFi is operating on:
    /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport scan
    From the results, identify the channels corresponding to 5G and 2G. For instance, in my case, 5G was on channel 36 and 2G was on channel 11.

Switching to the 5G Channel

Once you've identified the 5G channel (e.g., channel 36), follow these steps:

  1. Turn off WiFi.
  2. Run the following command, replacing 36 with your 5G channel number:
    sudo /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -c=36
  3. Turn WiFi back on.

Checking JoinMode Setting

It's also a good idea to check the `JoinMode` setting:

sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport prefs

Ensure it's set to Preferred. If not, you can set it using:

sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport prefs JoinMode=Preferred

Conclusion

With these steps, you should be able to enjoy a faster 5 GHz connection on your Mac.

Note: Always exercise caution when using sudo commands. Ensure you understand the command's purpose and potential impact.

Additional Notes

macOS (like many operating systems) has its own algorithms for choosing which WiFi band to connect to, based on a variety of factors including signal strength, interference, and past connection history. The instructions provided are a way to manually force the connection to a specific channel, but it's not a permanent solution.

Here are a few additional suggestions to help ensure a more consistent 5 GHz connection:

  • Separate SSIDs: If possible, configure your router to broadcast separate SSIDs for the 2.4 GHz and 5 GHz bands. This way, you can choose to connect to the 5 GHz band explicitly.
  • Router Placement: Ensure your router is placed in an optimal location. 5 GHz signals don't penetrate walls and other obstacles as well as 2.4 GHz signals. If you're closer to the router, your device is more likely to choose the 5 GHz band.
  • Update Firmware: Ensure your router's firmware is up to date. Manufacturers often release updates that improve performance and connection stability.
  • Network Prioritization: In the Network settings on your Mac, you can prioritize which networks to connect to first. If you have separate SSIDs for 2.4 GHz and 5 GHz, make sure the 5 GHz network is at the top of the list.
  • Forget Network: If you've previously connected to both the 2.4 GHz and 5 GHz bands, forget the 2.4 GHz network in your WiFi settings to prevent your Mac from connecting to it.
  • Third-Party Tools: There are third-party applications available that can give you more control over your WiFi connection on macOS. One such tool is "WiFi Explorer," which provides detailed information about networks and can help diagnose issues. Remember, while the 5 GHz band offers faster speeds, its range is shorter than the 2.4 GHz band. If you're far from the router or there are many obstacles in the way, your Mac might choose the 2.4 GHz band because it provides a more stable connection, even if it's slower.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment