In my application logs, I am seeing
could not receive data from client: Connection reset by peer being logged by my Heroku Postgres database.
This error message means that the Postgres client (usually a Heroku dyno or an external database connection) did not terminate the connection cleanly.
As explained here, https://devcenter.heroku.com/articles/postgres-logs-errors#log-errno-104-connection-reset-by-peer this can occur when network connectivity is interrupted. This is usually intermittent and will resolve when connectivity recovers.
Another cause can be if the server processes are terminated early for some reason. With Rails applications using Unicorn for example,
unicorn-worker-killer is a popular gem for managing the effects of memory increases over time. A side effect of this (along with other similar gems that kill processes) is that Postgres connections will usually not be closed cleanly and this would also cause the
Connection reset message to be logged.