How do I fix the "Could Not Translate Hostname to Address" error when connecting to PostgreSQL?

A “could not translate hostname to address” error occurs when you use the wrong DNS hostname or there are underlying problems with DNS resolution. The full error message may look like this:

psql: could not translate host name "cluster-do-user-1234567-0.db.ondigitalocean.com"
to address: Name or service not known

If you are getting this error, first verify that you are using the correct hostname to connect by following How to Connect to PostgreSQL Database Clusters. Then, verify whether the machine you’re connecting from has problems with DNS resolution by following Why does my domain fail to resolve?

To get started with DNS, see our community tutorial series, An Introduction to Managing DNS, and Retrieve DNS Information with dig.

Verify the hostname and confirm the database exists in the specified cluster.
Use the command CREATE EXTENSION vector; instead of pgvector.
Add the –no-role-passwords flag to the pg_dumpall command.