Troubleshooting Database Connection Issues for PostgreSQL
This article introduces some reasons why you cannot connect to PostgreSQL remotely and how to solve the remote database connection issues.
1> PostgreSQL service is not running.
2> The DB user does not have correct password or permission.
3> Firewall restricts IP connection on the “Security” page.
4> Remote Connection issue between your local server to our PostgreSQL.
5> The MySQL remote connection port is blocked by your server or ISP.
6> Wrong PostgreSQL connection information defined in application.
PostgreSQL service is not running
1) Please check the status on the “Overview” page of your application in the Control Panel.
2)Running the command “ps -ef | grep postgres” on web shell to check the PostgreSQL status. The service is working if the result is as the following screenshot shows.
If your PostgreSQL service is not working, please contact us at email@example.com.
The DB user does not have correct password or permission
You can connect to PostgreSQL via pgadmin to check if the username and password are correct. About how to access PostgreSQL via pgadmin, please refer to this documentation.
Firewall restricts IP connection on the “Security” page.
If you have enabled Firewall Rules under the “Security” tab, it will restrict the remote connection. Only the listed IPs will be allowed to connect to your application.
Solution: You can add more allowed IPs to the Firewall(a maximum of 5 IPs or IP ranges).
Or you just stop the Firewall service to allow connections from all IPs.
Remote Connection issue between your local server to our PostgreSQL
We can use “ping” and “tracert” commands on your local computer to test the remote connection.
1. Use Ping to check the connection issue
Get the PostgreSQL package host IP on the Overview page in the Control Panel.
As our PostgreSQL server do not allow ping function. You can ping the gateway of the PostgreSQL package on local pc to test the connection between local PC and PostgreSQL server. If the results like the following screenshot, it is normal. If it shows time out, please check your local network.
2. Use “Tracert” comamnd to check the connection issue
You can use the “tracert” command on most operation system to test the connection.
Mac / Linux:
Please run “yum -y install traceroute” or “apt-get install traceroute” to install traceroute first.
1.Open a Terminal window.
<postgresqlhostip>" in the terminal and hit enter.
1.Open the Start menu.
2.Click on Run.
3.Type "cmd" and press "OK" to open a command prompt.
<postgresqlhostip>" and hit enter.
<postgresqlhostip> should be filled in with your PostgreSQL hostname or host IP. If the result is like the following screenshot shows, it is normal. If the tracert process cannot complete, please check your local network.
The PostgreSQL remote connection port is blocked by your server or ISP
We can use telnet command to test if the port is blocked by your server or ISP.
If we want to test if the port 15498 is blocked, we can use “telnet 22.214.171.124 15498” .
If the telnet command cannot be recognized on your local PC, please install a telnet client first.
To install a telnet client,
Centos: # yum -y install telnet
Ubuntu & Debian: # apt-get install telnet
Wrong PostgreSQL connection information defined in the application
Please refer to the article "Connecting to PostgreSQL Database via Different Program Language" to check your database connection information in your codes.