H13
- What the socket did
- Accepted, then closed with nothing written
- Documented trigger
- Server timeout under 30 seconds; keep-alive race
Heroku H13 means your dyno accepted a connection and closed it without writing a response. Learn the keep-alive race, Unicorn timeout cause and per-server fixes.
Heroku H13 means a process in your web dyno accepted a connection and then closed the socket without writing anything, so the router returned a 503. The two documented causes are a server timeout shorter than 30 seconds that fires before a worker handles the request, and a keep-alive idle timeout under 90 seconds that races the router.
Four quick questions, then a straight answer.
From your answers, this is quietly costing you traffic and nobody has the hours to chase it. Scaplet finds every affected page, drafts the fixes and tracks how AI answers mention you.
A data platform shipped 46 fixes without a ticket.
This looks handled. Re-check after a redesign, a migration or a big content push; that is when it breaks.
Your site is small and you have the time. Work through the steps on this page, starting with the pages that get the most traffic.
2010-10-06T21:51:37-07:00 heroku[router]: at=error code=H13 desc="Connection closed without response" method=GET path="/" host=example-app-1234567890ab.herokuapp.com fwd=17.17.17.17 dyno=web.1 connect=3030ms service=9767ms status=503 bytes=0The same article warns that with Unicorn or Gunicorn, your main worker can time out and kill web workers. Gunicorn restarts a worker that has not completed any work within the last 30 seconds by default, and Heroku's Gunicorn guide shows --timeout for lowering it. If requests queue behind slow ones, workers hit that timeout while requests wait. Fix the slow request, add worker processes, or tune the timeout deliberately.
web: gunicorn hello:app --timeout 10const server = app.listen(process.env.PORT);
// milliseconds; Heroku recommends 90 seconds or greater
server.keepAliveTimeout = 95 * 1000;persistent_timeout 95web: gunicorn hello:app --keep-alive 95The recommendation is to set server idle connection timeouts to 90 seconds or greater so the router initiates the close. The defaults of common servers are below that, which is why this shows up as sporadic H13s on an otherwise healthy app.
| Server | Setting | Default | Safe for Heroku as is? |
|---|---|---|---|
Node.js http | server.keepAliveTimeout | 5000 ms (5 seconds) | No - raise it above 90 seconds |
| Puma | persistent_timeout | 65 seconds | No - raise it to 90 or more |
| Gunicorn | --keep-alive | 2 seconds | No - raise it, or confirm your worker class |
Gunicorn's keepalive setting is described as "the number of seconds to wait for requests on a Keep-Alive connection". Check that your worker class honors it before relying on it. Node's server.keepAliveTimeout is documented as milliseconds of inactivity before a socket is destroyed, with a server.keepAliveTimeoutBuffer added on top.
Run heroku logs --dyno router --tail and note the connect and service values on each H13. Compare them with your server's timeout and keep-alive settings.
Run heroku logs --source app --tail and check for the server's own timeout or worker-killed message at the same timestamp.
If it is lower, apply the table above first. It is a one-line change.
Heroku's request-timeout article lists Unicorn or Gunicorn with more worker processes as the most effective way to improve queueing inside a dyno.
4 questions people ask next, answered from the sources on this page.
A process in the web dyno accepted a connection and closed the socket without writing a response. Heroku names a server timeout shorter than 30 seconds, such as Unicorn's, and a keep-alive idle timeout shorter than the router's 90 seconds as the documented causes.
Likely the keep-alive race. The router closes idle pooled connections after 90 seconds, and a server with a shorter idle timeout may close the same connection while the router sends a request on it. Raise the server idle timeout to 90 seconds or more.
It starts in the dyno, so the fix is in your server or app configuration, not on Heroku's side. Check your server's timeout and keep-alive settings and look for workers being killed.
H13 is a socket that closed with nothing written. H18 is a socket that connected and sent some data but was destroyed before a complete response, or a server that responded before reading the whole request body.
Run the free audit, then approve the fixes. Every change can be undone.