Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#4072·htmx

HTMX 4 hx-sse:connect gets stuck while trying to reconnect when server is down

Author: taaiCreated Sep 13, 2026Updated Sep 13, 2026

I'm using HTMX 4.0.0 and hx-sse, I'm testing the "persistent connections".

The reconnect works. But only if the backend server is turned on. If I shut down the back-end server, the hx-sse tries to reconnect and gets stuck in a pending state. I started the back-end server, but the hx-sse did nothing. Is there a timeout option to cancel the request and try again...? I suspect that it gets stuck because there is no timeout on creating a connection.

Tried Firefox and Chromium. Backend server was on my local computer.

I did everything per documentation, also tried configuration settings.

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>test</title>
    <meta name="htmx-config" content="sse.reconnect:true sse.pauseOnBackground:false">
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/htmx.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/ext/hx-sse.min.js"></script>
</head>
<body>
    <div hx-sse:connect="/events"></div>
</body>
</html>

Source: bigskysoftware/htmx

View original on GitHubView discussion on GitHub