Fix: SignalR 404 Negotiation Error - Dev Fix in 30 Seconds

Published: Jun 04, 2026 · By Kumar Kunal

The Error

Failed to load resource: the server responded with a status of 404 (Not Found)
Error: Failed to complete negotiation with the server

Quick Fix - 1 Minute

// Program.cs - Dev Fix: Map SignalR hub BEFORE app.Run()
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSignalR();
var app = builder.Build();

app.MapHub("/chathub"); // Must be before app.Run() app.Run();

Why This Happens

SignalR returns 404 on /negotiate when the hub endpoint isn't mapped or middleware order is wrong. App.UseRouting() must come before app.MapHub(). In .NET 8 minimal APIs, order matters more than MVC.

Best Practice for .NET 8

  1. Call app.MapHub() after app.UseRouting() but before app.Run()
  2. Check hub path matches client: new HubConnectionBuilder().WithUrl("/chathub")
  3. For Blazor Server: ensure @rendermode InteractiveServer is set

Related Dev Fixes

Found this helpful?

Master C# with our complete course. Real apps, real skills, job-ready in 2 hours.

Share this fix: Twitter LinkedIn

Comments on Fix: SignalR 404 Negotiation Error - Dev Fix in 30 Seconds (0)

No comments yet. Be the first to share your thoughts!