When connecting to PostgreSQL I get a Could Not Translate Hostname to Address error

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:

  • Verify that your hostname is correct.

  • Verify whether the machine you’re connecting from has problems with DNS resolution.

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