Skip to content

MCP OAuth intermittently fails on Windows with socket error 10013 #4463

Description

@msosav

Describe the bug

OAuth authentication for a remote HTTP MCP server intermittently fails before the browser authorization flow opens.

OAuth authentication failed: MCPOAuthError: An attempt was made to 
access a socket in a way forbidden by its access permissions. (os error 10013)

Affected version

1.0.79

Steps to reproduce the behavior

  1. Configure an OAuth-enabled remote HTTP MCP server without specifying auth.redirectPort.
  2. Start a new Copilot CLI session.
  3. Run /mcp auth <server-name>.
  4. Authentication may fail while creating the local OAuth callback listener.

Expected behavior

Copilot CLI should select an available callback port. If binding fails, it should retry using another port and report the attempted port if all retries fail.

Additional context

Workaround

Pinning a known-available port and restarting Copilot CLI allowed authentication to complete:

"auth": {
  "redirectPort": 47000
}

The problem is intermittent. Authentication later worked without the override, possibly because credentials were cached or automatic port selection chose a usable port.

Environment

  • Copilot CLI: 1.0.79
  • Package: 1.0.79-9
  • OS: Windows x64

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions