Question

PSQL connection is failing from trusted IP with the message no pg_hba.conf entry for host

Hi. I copy/pasted the psql connection string for my managed database from the managed database dashboard. I have my public-facing IP address as a Trusted Source.

When executing the psql command I get this reponse:

psql: error: connection to server at <DB HOST> (<DB HOST IP), port <DB PORT> failed: could not initiate GSSAPI security context:  The operation or option is not available: Credential for asked mech-type mech not found in the credential handle
connection to server at <DB HOST> (<DB HOST IP), port <DB PORT> failed: SSL error: certificate verify failed
connection to server at <DB HOST> (<DB HOST IP), port <DB PORT> failed: FATAL:  no pg_hba.conf entry for host "<MY TRUSTED IP>", user "<MY DB USER>", database "<MY DATABASE>", no encryption

I have installed the CA Certificate locally.

What am I missing?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
December 17, 2024

Hi there,

Can you share the exact psql command that you are using to connect?

Usually the following should work when using the CA certificate:

PGPASSWORD=your_password psql -U doadmin -h cluster-do-user-1234567-0.db.ondigitalocean.com -p 25060 -d defaultdb --set=sslmode=require --set=sslrootcert=path/to/your-ssl.crt

Also can you confirm how did you install the certificate and what is the exact OS that you are using locally?

Besides that, what is the exact psql CLI version that you are using?

- Bobby

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.