Blazor Server circuit drops with Server timeout elapsed
Your error
Error: Server timeout elapsed without receiving a message from the server.1 more line it can showFix it fast
Most common cause, 1 of 3Server pings arrive late because of network latency
Give the client more time and give the server the same headroom.
<!-- Components/App.razor -->
<script src="@Assets["_framework/blazor.web.js"]" autostart="false"></script>
<script>
Blazor.start({
circuit: {
configureSignalR: function (builder) {
builder.withServerTimeout(60000).withKeepAliveInterval(15000);
}
}
});
</script>
// Program.cs
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents()
.AddHubOptions(options =>
{
options.ClientTimeoutInterval = TimeSpan.FromSeconds(60);
options.HandshakeTimeout = TimeSpan.FromSeconds(30);
});Short answer
Server timeout elapsed without receiving a message from the server means the browser's SignalR client heard nothing from the server within its server timeout, 30 seconds by default. Pings sent by the browser do not reset it. Raise withServerTimeout in Blazor.start, keep it at least twice the server KeepAliveInterval, and keep background tabs awake. Applies to .NET 10 and 11.
Which cause do you have?
Find every place the app sets SignalR timing. If nothing turns up, the 30-second default is too short for the network (cause 1). A server KeepAliveInterval or a client timeout that breaks the two-to-one rule is cause 2. If both look right and the drop only happens in a hidden tab, go to cause 3.
grep -rnE "KeepAliveInterval|ClientTimeoutInterval|withServerTimeout|withKeepAliveInterval|serverTimeoutInMilliseconds" --include=*.cs --include=*.razor --include=*.cshtml --include=*.js .Then find the line you see in this list and open its fix:
- 1Server pings arrive late because of network latency
Drops happen for users far from the server or on slow links, while local testing is fine, and the grep finds no custom timing - 2Client and server timing values no longer match
The grep shows KeepAliveInterval raised on the server, or withServerTimeout lowered in the browser, so the timeout is less than double the keep-alive - 3The browser froze the tab in the background
The error shows up when users return to a tab that sat in the background for a while; a tab kept in front never drops
What does the error look like?
Error: Server timeout elapsed without receiving a message from the server.Connection disconnected with error 'Error: Server timeout elapsed without receiving a message from the server.'.
Cause 1 of 3
Server pings arrive late because of network latency
You seeDrops happen for users far from the server or on slow links, while local testing is fine, and the grep finds no custom timing
Check
Blazor raises Server timeout elapsed when no message from the server reaches the browser within withServerTimeout, which defaults to 30 seconds while the server pings every 15. Microsoft's Blazor SignalR guide names internal network and Internet latency as a common reason for these ping timeouts in deployed apps. The SignalR client restarts that timer only when it receives data, so pings or invocations sent from the browser change nothing.
grep -rn "autostart" Components/App.razor Pages/_Host.cshtmlFix
Give the client more time and give the server the same headroom. Leave the keep-alive at 15 seconds on both sides so the two-to-one rule still holds.
<!-- Components/App.razor -->
<script src="@Assets["_framework/blazor.web.js"]" autostart="false"></script>
<script>
Blazor.start({
circuit: {
configureSignalR: function (builder) {
builder.withServerTimeout(60000).withKeepAliveInterval(15000);
}
}
});
</script>
// Program.cs
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents()
.AddHubOptions(options =>
{
options.ClientTimeoutInterval = TimeSpan.FromSeconds(60);
options.HandshakeTimeout = TimeSpan.FromSeconds(30);
});Verify
Leave a page open on the slow connection for several minutes. The reconnect overlay no longer appears and the console stays free of the timeout line.
dotnet runConfirmed by learn.microsoft.com
Cause 2 of 3
Client and server timing values no longer match
You seeThe grep shows KeepAliveInterval raised on the server, or withServerTimeout lowered in the browser, so the timeout is less than double the keep-alive
Check
The timeout fires when the server's ping interval is too close to the client's waiting time. The guide says the server timeout must be at least double the Keep-Alive interval and the Keep-Alive value should be the same on server and client. Raising KeepAliveInterval to 30 seconds in AddHubOptions while the browser still waits 30 seconds breaks that rule on every quiet minute.
grep -rn "AddHubOptions" -A6 Program.csFix
Set both values together. If the server keeps a longer KeepAliveInterval, make the client timeout at least twice that value and pass the same keep-alive to the client builder.
// Program.cs: server pings every 20 s
.AddHubOptions(options =>
{
options.KeepAliveInterval = TimeSpan.FromSeconds(20);
options.ClientTimeoutInterval = TimeSpan.FromSeconds(40);
});
// Components/App.razor: client waits at least 2 x 20 s
builder.withServerTimeout(40000).withKeepAliveInterval(20000);Verify
Run the grep again. Every timeout is at least twice its keep-alive, and an idle page stays connected.
grep -rnE "KeepAliveInterval|withServerTimeout" --include=*.cs --include=*.razor .Confirmed by learn.microsoft.com
Cause 3 of 3
The browser froze the tab in the background
You seeThe error shows up when users return to a tab that sat in the background for a while; a tab kept in front never drops
Check
Some browsers freeze or sleep inactive tabs to save resources, and Microsoft's SignalR JavaScript client docs warn that this can close SignalR connections. A frozen tab cannot process the server's pings, so the Blazor circuit hits the server timeout and drops.
grep -rn "navigator.locks" wwwroot/ Components/Fix
Hold a shared Web Lock while the circuit is needed, which is one of the signals browsers use to keep a tab awake. Release it when the tab may sleep again.
var lockResolver;
if (navigator && navigator.locks && navigator.locks.request) {
const promise = new Promise((res) => { lockResolver = res; });
navigator.locks.request('blazor_circuit_lock', { mode: "shared" }, () => promise);
}
// call lockResolver() when the tab is allowed to sleepVerify
Put the tab in the background for the time that used to break it, then return. The page responds without the reconnect overlay.
dotnet runConfirmed by learn.microsoft.com
How do I stop it coming back?
- Change the server and client timing values in the same commit, with a comment next to AddHubOptions that states the two-to-one rule.
- Test idle pages from a distant region before release, because local runs hide the latency that triggers the timeout.
- Leave KeepAliveInterval at its 15-second default unless you have measured a reason: a lower value adds ping load, and a higher one forces a longer client timeout.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: Raheeb, Loade Driver, Dhero.