How should I interpret Heroku H18 errors?

Solution 1:

This typically indicates either that the user's network was disconnected (e.g. this happens with some frequency for mobile users) or the end-user closed their browser or similar (e.g. pressed Stop, went to a different page, etc).

You can safely ignore those that are tagged as being client-end in nature with "sock=client", but might want to investigate those that are being closed by the Server end ("sock=server").

Solution 2:

Edit (Aug 10, 2015): My answer below for H18 errors is out of date. Heroku has changed the behavior of H18 errors making them more specific (and serious) than before. This Answer is now more correct.


H18 Errors

I recently asked Heroku support about a significant number of H18 errors (3-4 an hour sometimes) my app was receiving and being surfaced in the Metrics section of the new Heroku dashboard (screenshot above). I referenced catsby's response on this thread and asked to confirm if they were in fact not actionable. This was the response I received from Heroku Support:

I just went through the last 24 hours of H18s on your app. They are all sock=client and looking at the User-Agent I see a lot of the usual culprits. Mobile browsers for the most part and also the latest Chrome which I have seen other apps have issue with as well since a few days ago. Unless you see a pattern such as for a particular URL or user then it often is just network issues.

[That these H18 errors are] Not actionable is not always true. Some apps do care about it, and sometimes it can also mean a client crash rather than a network error. Browsers do crash from time to time but in particular mobile browsers can be pretty fragile. If an app uses a lot of assets and triggers "page not responding" errors you might see spikes in H18s. In that case sometimes there is something you can do about it. Other apps are serviced entirely in wired networks and would never expect it, in that case there could be a faulty switch or firewall. For the sake of transparency we still want to report these errors as there is no way to tell if they are or aren't actionable.

To summarize, most of the time you can ignore them if they are sock=client errors, but that does indicate that clients are disconnecting which could indicate a real issue depending on how your application is networked to its clients (e.g. mobile or really bad network connection)... but probably you can safely ignore them.

Solution 3:

FYI: Ben Sheldon's and catsby's answers are no longer correct. They was at the time of writing, but things have changed. H18s are now always sock=server. Heroku added a new error code H27 for sock=client.

Details here: https://devcenter.heroku.com/changelog-items/662

H18 should be taken more seriously now as they are definitely an issue with your service. H27s can generally be safely ignored as they are an issue with the client.

Solution 4:

There is another case that can cause this error that is not documented by Heroku.

If your server responds to the request and closes the connection without reading the request body, then the router will respond with the H18 error. The Heroku router logs will show sock=backend.

In this case your server is not doing anything wrong with respect to the HTTP spec. It's a bug with the Heroku router.

I contacted Heroku technical support about this, and they confirmed the issue. It will be fixed in a new version of the router they are implementing.

The workaround is to always ensure the request body is read on the backend server before closing the connection.