Symptom

You cannot find the IP address of your computer or add it to an IP address whitelist of your AnalyticDB for PostgreSQL instance.

Procedure

  1. Follow these steps to add 0.0.0.0/0 to an IP address whitelist of your AnalyticDB for PostgreSQL instance:
    1. Log on to the AnalyticDB for PostgreSQL console.
    2. In the top navigation bar, select the region where the target instance resides.
    3. Find the target instance and click its ID. The Basic Information page appears.
    4. In the left-side navigation pane, click Security Controls. The Security Controls page appears.

    5. On the Whitelist Settings tab, find the IP address whitelist labeled default and click Modify to its right. The Modify Group dialog box appears.
    6. In the White List field, delete the IP address 127.0.0.1 and enter 0.0.0.0/0.
      Note 0.0.0.0/0 indicates that all entities are allowed to access the instance. However, this is risky, so we recommend that you delete it after you no longer need it.
    7. Click OK.
  2. Install the psql CLI client. For more information, see Connect to an AnalyticDB for PostgreSQL instance. Then, run the following command to connect your computer to a database on the instance:
    psql -h yourgpdbaddress.gpdb.rds.aliyuncs.com -p 3432 -d postgres -U gpdbaccount

    Parameter description:

    • -h: the host address used to connect to the database.
    • -p: the port used to connect to the database.
    • -d: the name of the database. The default database is postgres.
    • -U: the account used to connect to the database.
    • You can run the psql --help command to view more options. You can also run the \? command to view more commands supported by the psql CLI client.
  3. After you connect to the database, run the following command in the SQL window to query the IP address of your computer:
    select * from pg_stat_activity;
    The value of the CLIENT_ADDR field is the IP address of your computer.
  4. In the AnalyticDB for PostgreSQL console, delete 0.0.0.0/0 from the default IP address whitelist and enter the IP address of your computer.