Failed to complete negotiation with the server 🟪 .NET

SignalR: Error: Failed to complete negotiation with the server / Failed to start the connection

The SignalR client couldn’t negotiate with the hub — wrong URL, CORS, authentication, or a proxy that blocks WebSockets/negotiate requests.

Seen on: .NET

Meaning

Negotiate is a POST to /hub/negotiate. 404 means wrong path/MapHub, CORS errors require AllowCredentials with specific origins, 401 means the token wasn’t sent (use accessTokenFactory). Load balancers need sticky sessions unless using SkipNegotiation with WebSockets.

Common causes

  • Hub URL or MapHub path mismatch
  • CORS not allowing the client origin with credentials
  • Missing auth token (accessTokenFactory)
  • Proxy/load balancer without WebSocket support or sticky sessions

⚡ Quick fix

  1. Check the network tab for the negotiate response code
  2. Configure CORS with WithOrigins + AllowCredentials
  3. Pass tokens via accessTokenFactory; enable sticky sessions or Azure SignalR

Detailed fix by platform

JavaScript

  1. javascript
    const conn = new signalR.HubConnectionBuilder()
      .withUrl("https://api.example.com/hubs/chat", { accessTokenFactory: () => token })
      .withAutomaticReconnect()
      .build();

How to diagnose

  1. Negotiate — Status code
  2. CORS — Console errors
  3. Proxy — WebSockets allowed?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.