All Products
Search
Document Center

Error: The server terminated the connection unexpectedly

Last Updated: Jun 20, 2019

Symptom

When you connect to an RDS for PostgreSQL or PPAS instance, one of the following two errors is reported:

  • server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.
  • Error connecting to the server: FATAL: no pg_hba.conf entry

Solution

An ECS instance cannot connect to an RDS instance via an intranet

  1. Check whether the private IP address of the ECS instance is added to the IP address whitelist for the RDS instance. If the whitelist does not contain this private IP address, see the specific solution

    s10

    s11

  2. Check whether the whitelist follows the 0.0.0.0 format.

    The valid format is 0.0.0.0/0, which indicates that all devices are allowed to connect to the RDS instance. This format has security risks. Exercise caution when you use this format.

  3. If the whitelist is set to the enhanced security mode, take these steps:

    • If you want to establish a connection via a VPC by using the private IP address of the ECS instance, ensure that this private IP address is added to the VPC group.
    • If you want to establish a connection via a classic network by using the private IP address of the ECS instance, ensure that this private IP address is added to the classic network group.

A device rather than an ECS instance cannot connect to an RDS instance

A device rather than an ECS instance can connect to an RDS instance only via the Internet. If the connection fails, take these steps:

  1. Check whether the IP address whitelist for the RDS instance is set. If the whitelist is not set, see Set the whitelist.

  2. Check whether the whitelist follows the 0.0.0.0 format.

    The valid format is 0.0.0.0/0, which indicates that all devices are allowed to connect to the RDS instance. This format has security risks. Exercise caution when you use this format.

  3. If the whitelist is set to the enhanced security mode, ensure that the public IP address of the device is added to the classic network group.

    The VPC group is unsuitable for communication via the Internet.

  4. If the whitelist is set, the connection fails probably because the public IP address of the device in the whitelist is not the real outbound IP address:

    • The public IP address is not fixed and may change.
    • The IP address query tool or website yields inaccurate results.

      For more information, see locate the local IP address.