Verifying the Connection to the PostgreSQL Database Server


On this page

Before you create a PostgreSQL instance, you must verify the connection to the PostgreSQL database server.


  1. Log on as the root user, and then go to the bin folder in the PostgreSQL installation directory.

  2. Establish the postgresql connection:

    • On a Unix computer, run the following command:

      ./psql -p port -U <database_user> -d <database_name> -h <hostname>
    • On a Windows computer, run the following command:

      psql.exe -p port -U <database_user> -d <database_name> -h <hostname>


      • database_user is a user that has permissions to perform backups and restores

      • database_name is the database that is available in the database server

      • hostname is the IP address or the fully qualified domain name of the computer that contains the database server


The following example verifies the connection to the demopgsql database:

[root@mpgstandby bin]# cd /usr/pgsql-13/bin

[root@mpgstandby bin]# ./psql -p 5432 -U postgres -d demopgsql -h mpgstandby

psql (13.0)

Type "help" for help.

demopgsql=# \q

[root@mpgstandby bin]#