You need to enable JavaScript to run this app.
RDS for PostgreSQL

RDS for PostgreSQL

Copy page
Download PDF
Connecting to an instance
Connecting to an instance via command line
Copy page
Download PDF
Connecting to an instance via command line
Adding an allowlist for the PostgreSQL instance IP addresses enables a successful connection to the instance. This topic introduces the procedure for connecting to a PostgreSQL instance via command line.​
Prerequisites​
  • An instance is created and in the Running state. For more details, refer to Creating an instance.​
  • If you are using an ECS instance for connection, please associate a private network and subnet to the instance.​
Procedure​
  1. Log on to the server that needs to connect to PostgreSQL, such as an ECS instance or local server.​
tip​
For details on how to log on to an ECS, refer to Log on to an ECS instance.​
  1. Use the command line to establish a connection.​
  • Once PostgreSQL is installed on the server, you can connect to the PostgreSQL database with the command line tool in the following method:​
  • ​
    psql -h <连接地址> -p <端口> -U <用户名> -d <数据库名称>​
    ​
danger​
Please use lower-case letters for ports (-p).​
Refer to the following table for a description of addresses and ports for PostgreSQL instances.​
​
Options​
Note​
Example​
-h​
The private or public network address of the PostgreSQL instance.​
Description:​
For information on how to get the private or public address, refer to Connecting to an instance via private network and Applying for or releasing a public network address.​
​
-p​
Port number of the PostgreSQL instance. You can connect to PostgreSQL instances after adding IP address allowlists to the PostgreSQL instances. This topic describes how to connect to a PostgreSQL instance via the client and command line tool. You can connect to PostgreSQL instances after adding IP address allowlists to the PostgreSQL instances. This topic describes how to connect to a PostgreSQL instance via the client and command line tool.​
5432​
-U​
Account name in the PostgreSQL instance.​
testuser​
-d​
database name required for login​
Description:​
You can omit the "-d" and enter the database name only.​
db01​
​
Example command:​
​
psql -h postgresbcc087e73689****.rds-pg.ivolces.com -p 5432 -U testuser -d db01​
​
​
​
Last updated: 2025.11.17 20:31:11