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

**Code:** `Failed to complete negotiation with the server` · **Category:** .NET · **Seen on:** .NET

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

## 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?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/dotnet/signalr-failed-to-complete-negotiation)
