PostgreSQL is an open source, object-relational database built with a focus on extensibility, data integrity, and speed. Its concurrency support makes it fully ACID compliant, and it supports dynamic loading and catalog-driven operations to let users customize its data types, functions, and more.
If you get an error when you try to connect to your PostgreSQL database cluster, there are several possible causes and fixes depending on the error. Look up the error you’re receiving below and try the suggested solutions.
Before you begin troubleshooting, check the DigitalOcean status page for ongoing issues in your database’s region.
psql: could not connect to server: Connection refused Is the server running on host "cluster-do-user-1234567-0.db.ondigitalocean.com" (HOSTNAME_DNS) and accepting TCP/IP connections on port 25060?
This error means that the server is denying the connection.
Connecting from a computer that is not allowed in the database’s inbound sources.
Using the wrong port in the connection string
Make sure your computer is allowed in your database’s inbound sources.
Check the port in the connection string.
If you still receive this error, you may have a firewall or local DNS issue.
psql: error: could not connect to server: could not connect to server: Operation timed out Is the server running on host "example-database-do-user-6607903-0.a.db.ondigitalocean.com" (126.96.36.199) and accepting TCP/IP connections on port 25060?
This error means that your database won’t allow you to connect to it from your current machine or resource.
psql: could not connect to server: Connection refused Is the server running on host "203.0.113.0" and accepting TCP/IP connections on port 25060?
This error means your computer can’t find a route to the database.
Using the wrong IP address in the connection string
Using the database’s private IP address in the connection string and trying to connect from a Droplet that isn’t allowed to access the VPC network
Check the IP address in the connection string or use the database’s hostname. We recommend using the hostname over the IP address because the IP address may change, but the hostname will always remain the same.
If you’re using the database’s private IP address, connect from a Droplet that meets the following criteria:
bash: postgresql://your_username:[email protected]:25060/defaultdb?sslmode=require: No such file or directory
This error means that the terminal couldn’t execute the command.
psqlbefore the text of the connection string to connect to the database. For detailed instructions, read How to Connect to PostgreSQL Databases with
psql: FATAL: password authentication failed for user "your_username"
This error means that the server rejected the credentials in the connection string.
Connecting to the wrong database cluster
Using the wrong username or password
psql: could not translate host name "cluster-do-user-1234567-0.db.ondigitalocean.com" to address: Name or service not known
This error means that
psql couldn’t find the host you were trying to connect to.
Using the wrong hostname
Problems with DNS resolution
If the hostname isn’t the problem, the computer you’re connecting from may be having problems with DNS resolution.
psql: FATAL: database "defaultdb" does not exist
This error means the server couldn’t find the database name you specified.
Connecting to the wrong cluster
Connecting to a database that doesn’t exist in the cluster
Make sure you’re using the right hostname for the cluster.
Check that you’ve created the database in the cluster.
psql: invalid URI query parameter: "some_param"
psql: invalid PARAM value: "some_value"
These errors mean that one of the arguments to
psql was incorrectly formatted.