- Plesk for Linux
It is not possible to connect to a remote PostgreSQL server from elsewhere:
PLESK_ERROR: Could not connect to server: connection refused
By default, PostgreSQL server allows connection from localhost only.
Note: This guide is intended for server administrators with SSH access to a server with PostgreSQL server. If you are a domain owner, please contact your service provider for assistance.
Enable remote access to PostgreSQL server:
Connect to the server where the PostgreSQL server is installed via SSH.
Get location of the
postgresql.conffile (default location is
# find / -name "postgresql.conf"
postgresql.conffile in a text editor (for example, the vi editor) and add the following line at the end of the file:
CONFIG_TEXT: listen_addresses = '*'
Now open the
/var/lib/pgsql/data/pg_hba.conffile in a text editor and add the following line at the end of the file:
CONFIG_TEXT: host samerole all 203.0.113.2/32 md5
- 203.0.113.2/32 - a remote IP address from which connection is allowed. To allow connections from any IP address, specify 0.0.0.0/0.
- md5 - an authentication method which requires a client to supply a double-MD5-hashed password for authentication.
For other authentication methods, refer to PostgreSQL documentation.
Restart PostgreSQL server to apply the changes:
# service postgresql restart