Linux & Networking

Configure Wi-Fi Priority with NetworkManager

Control which saved network Linux connects to first using nmcli autoconnect priority — no config-file editing, survives reboots.

When several Wi-Fi networks are in range and saved, NetworkManager picks one by its own rules — often not the one you want. The fix is a per-connection number called autoconnect priority: higher wins.

How autoconnect priority works

Each saved connection has a connection.autoconnect-priority integer, defaulting to 0. When the system is not already connected and multiple saved networks are detectable, NetworkManager attempts them in descending priority order. Only connections with autoconnect=yes are considered.

Two rules that cause most confusion:

  • Priority is compared only among connections that could connect right now (in range, correct security). A high-priority network that isn’t visible is simply skipped.
  • If two networks tie, the one that was active last / has the better signal wins — ties are not stable.

Setting priority on all saved networks

List everything first, including non-active profiles:

nmcli -f NAME,AUTOCONNECT,AUTOCONNECT-PRIORITY connection show

Then set a sensible ladder. A common pattern: mobile/hotspot highest, home next, public networks lowest (or disabled):

nmcli connection modify VerizonWifi   connection.autoconnect-priority 100
nmcli connection modify TMOBILE       connection.autoconnect-priority 50
nmcli connection modify OfficeGuest   connection.autoconnect-priority 0
nmcli connection modify AirportFree   connection.autoconnect no

autoconnect no is the strong tool: it stops a profile from ever connecting on its own, while still letting you join it manually.

Verifying and testing

# See the effective values
nmcli -f NAME,AUTOCONNECT-PRIORITY connection show --active

# Force a reconnect to observe the new ordering
nmcli device wifi reconnect

To watch which SSID it actually selects, check after a brief disconnect:

nmcli -f DEVICE,TYPE,STATE device status
nmcli -f GENERAL.CONNECTION device wifi list | head

Restoring defaults

# Back to 0 for a specific profile
nmcli connection modify OfficeGuest connection.autoconnect-priority 0

# Re-enable autoconnect if you disabled it
nmcli connection modify AirportFree connection.autoconnect yes

There is no single “reset all” command; set each profile you touched back to 0 and autoconnect yes.

Common problems

The setting reverts after a reboot

You edited the wrong profile. NetworkManager often keeps one profile per SSID per band/security, and GUI changes can create duplicates. List all profiles, not just active ones:

nmcli connection show

Set priority on every profile that matches the SSID you care about, or delete the duplicates (nmcli connection delete <name>).

“Error: failed to modify connection” / permission denied

You need sudo or membership in the right group for system-wide changes. For a per-user setup, make sure your user session owns the connection (usually already the case for profiles you created).

A higher-priority network still loses

Usually because it isn’t actually connectable at that moment (hidden SSID, wrong PSK, 5 GHz vs 2.4 GHz mismatch in the profile). Temporarily drop other networks and confirm the target profile connects on its own before relying on priority to order things.

Sources and upstream documentation