I tried to query my Amazon Relational Database Service (Amazon RDS) for PostgreSQL or Amazon Aurora PostgreSQL-Compatible Edition DB instance. But when I do, I receive one of the following errors: "could not send data to client" or "could not receive data from client"
Resolution
A backend process in an Amazon RDS DB instance must be able to send or receive data from a client. If the backend process can't send or receive data, then the backend process records one of the errors in the PostgreSQL log. To troubleshoot this error, complete the following steps.
Check the aliveness of the client
Check the aliveness of the client process first. If the client process crashes because of out-of-memory (OOM), for example, then the session might be incorrectly terminated. This termination can cause either of these errors to occur.
Shorten tcp_keepalives_idle and tcp_keepalives_interval parameters
If the process time for a query is too long, then the session might be incorrectly terminated from the client. To resolve this issue, increase the client's timeout setting. You can also shorten the tcp_keepalives_idle and tcp_keepalives_interval parameters to check the aliveness of the client from the backend process. For more information, see Working with parameter groups.
To check the default values of tcp_keepalives_idle and tcp_keepalives_interval, use a PostgreSQL client such as psql to run the following command:
SELECT name, setting FROM pg_settings WHERE name LIKE 'tcp_keepalives_%'
Check the connectivity
If the error occurs irrespective of fewer query processing times, then check the connectivity between the client and the DB instance.
Check if the error occurs after failover from rdsadmin session
If the error occurs after failover from an rdsadmin session, then ignore the error.
Related information
PostgreSQL error codes (On the PostgreSQL website)
Connections and authentication (On the PostgreSQL website)
Setting TCP keepalives parameters