Addressing H12 Errors (Request Timeouts)
Last updated February 15, 2022
Table of Contents
This article contains steps for addressing a sudden increase in the number of H12 Request Timeout errors in your app. These errors occur when an HTTP request takes longer than 30 seconds to complete. They’re often caused by:
- Long-running requests, such as expensive queries or a slow external API call.
- Insufficient concurrency resulting in high request queue times during spikes in traffic.
For long-term mitigation, see Preventing H12 Errors (Request Timeouts).
Remediating a High Number of H12 Errors
Execute each remediation step in the following order. It may not be necessary to complete each step to achieve a reduction in H12 errors. Check the Heroku Dashboard after each step to see if the number of errors has decreased.
A restart cancels long-running requests. Restarting can resolve H12 issues because freshly-booted dynos receive requests without interference from long-running requests.
If the spike in H12 errors coincides with a specific deployment, the code change may have caused long-running requests.
Using the Heroku CLI, run
heroku rollback to roll back to the last release.
Or, in the Activity tab of the Heroku Dashboard, click Roll back to here beside the last release.
Scale Dynos to Handle Increased Traffic
Restarting dynos doesn’t help with issues caused by traffic spikes. However, adding or upgrading dynos provides more resources to address the increased throughput.
Check throughput in the Heroku Dashboard or attached monitoring add-on (if applicable). See the Metrics article for more information on throughput.
Add Additional Dynos
A larger dyno pool provides more processes to address increased throughput, reducing timeouts as request queue times shorten.
Add additional dynos via the Heroku Dashboard or the CLI. See Scaling for full instructions.
The application’s dynos may be undersized for its concurrency settings. Upgrading dynos to a higher tier provides more compute resources for processes to use.
Check the Heroku Dashboard. Upgrade dynos if either are true:
- Dyno memory usage is near or above 100%.
- Dyno load is near or above the acceptable load for your dyno type.
The remediation steps in this article serve to address immediate H12 errors. It is important to address any slow-performing code within the application or capacity issues to minimize these errors in the future. Review Preventing H12 Errors (Request Timeouts) for tips for future mitigation.