Fix VS Code Settings Sync Failed: Turning on Settings Sync failed: Cannot sign in

intermediate๐Ÿ’ป VS Code2026-03-19| Visual Studio Code 1.75+ on Windows 10/11, macOS 12+, Ubuntu 20.04+

Error Message

Turning on Settings Sync failed: Cannot sign in
#vscode#settings-sync#sign-in#github

The Error

You open VS Code, hit Turn On Settings Sync, pick GitHub or Microsoft โ€” and get this:

Turning on Settings Sync failed: Cannot sign in

No details. The dialog closes. Settings Sync stays off.

This error looks simple, but depending on your environment it can come from half a dozen different places โ€” a stale token, a broken keychain, a proxy intercept, or Snap sandboxing on Linux.

Root Causes

  • Keychain/credential store not accessible (most common on Linux)
  • Stale or corrupted OAuth tokens cached by VS Code
  • Network/proxy blocking the OAuth callback URL
  • Browser can't complete the auth flow (redirects fail silently)
  • VS Code extension host crashed mid-auth
  • Corporate firewall blocking vscode:// URI scheme

Fix 1: Clear Cached Credentials (Start Here)

Most of the time, stale token data is the culprit. Clear it before touching anything else.

Open the Command Palette (Ctrl+Shift+P / Cmd+Shift+P) and run:

Settings Sync: Reset Extension

Then sign out of all accounts:

Accounts: Remove Account

Restart VS Code completely โ€” not just reload window โ€” then try enabling Settings Sync again.

Fix 2: Delete the Keychain Entry Manually

Still broken? VS Code may have left a corrupted entry in your OS credential store.

Windows

Open Credential Manager โ†’ Windows Credentials. Look for entries starting with vscode or GitHub. Delete them all, then retry.

macOS

Open Keychain Access and search for vscode. Delete any VS Code or GitHub entries. Or handle it from Terminal:

security delete-generic-password -s "VS Code" -a "$(whoami)"

Note: the service name in Keychain can vary โ€” confirm the exact entry name in Keychain Access before running this.

Linux

Linux is where this breaks most often. VS Code needs a keyring daemon running. On minimal desktops and headless setups, it's usually missing:

# Install gnome-keyring if missing
sudo apt install gnome-keyring libsecret-1-0 libsecret-tools

# Start the keyring daemon (add to your shell rc to persist)
export $(gnome-keyring-daemon --start --components=secrets)

# Verify it's running
ps aux | grep keyring

On a server or CI with no display, skip the keyring entirely:

code --password-store=basic

Make it permanent with an alias:

alias code='code --password-store=basic'

Fix 3: Fix the OAuth Browser Redirect

Here's what the auth flow actually does: VS Code opens a browser โ†’ you approve OAuth โ†’ the browser redirects back to VS Code via a vscode:// URI. If your system doesn't handle that URI scheme, the browser just sits there. VS Code never gets the token. No error message โ€” just silence.

On Linux (xdg-open not configured)

# Register the vscode URI handler
xdg-mime default code-url-handler.desktop x-scheme-handler/vscode

# Verify
xdg-mime query default x-scheme-handler/vscode
# Should output: code-url-handler.desktop

Missing the desktop file entirely? Reinstall VS Code from the official .deb/.rpm package. Snap regularly breaks URI handlers โ€” see below.

Snap VS Code on Ubuntu

Snap's sandbox cuts off the vscode:// redirect. Switch to the official Microsoft repo instead:

sudo snap remove code

# Add Microsoft repo
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/
echo "deb [arch=amd64] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list

sudo apt update && sudo apt install code

Fix 4: Proxy or Firewall Blocking Auth

Behind a corporate proxy? The OAuth callback can get intercepted before it reaches VS Code. Add your proxy to settings.json:

// In settings.json
"http.proxy": "http://your-proxy:port",
"http.proxyStrictSSL": false

Also whitelist these domains in your firewall rules:

  • github.com
  • api.github.com
  • login.microsoftonline.com
  • vscode.dev
  • insiders.vscode.dev

Fix 5: Wipe VS Code Auth State Completely

Nothing worked? Do a hard reset. This only clears local auth tokens and sync metadata โ€” your actual settings stay in the cloud.

Windows

rmdir /s /q "%APPDATA%\Code\User\sync"
del "%APPDATA%\Code\User\settings.json"  # Only if you're okay re-syncing from cloud

macOS

rm -rf "$HOME/Library/Application Support/Code/User/sync"

Linux

rm -rf "$HOME/.config/Code/User/sync"

Restart VS Code and try again.

Verify the Fix

  • Open Command Palette โ†’ Settings Sync: Show Synced Data. You should see a timeline with a recent entry.
  • Check the account badge in the bottom-left Activity Bar โ€” your GitHub or Microsoft username should appear there.
  • Toggle any setting, wait 30 seconds, then open VS Code on a second machine or check https://vscode.dev. The change should show up.

Prevention

  • On Linux, install VS Code from the official Microsoft repo โ€” not Snap.
  • Running i3, sway, or another minimal WM? Add gnome-keyring-daemon to your autostart so it's always available.
  • Keep VS Code updated. Auth flows get patched regularly.
  • After rotating GitHub tokens or revoking OAuth apps, re-authorize VS Code under GitHub Settings โ†’ Applications โ†’ Authorized OAuth Apps.

Related Error Notes