Cannot connect to PostgreSQL database through PHP

Asked by:
HubFans / n/a Points
Time:
2016-06-16 5:07 am EST
Category:
Databases
Hits:
315
I've created a PostgreSQL database and user in my Cpanel. In PHP I am trying to connect to that database using pg_pconnect(), and getting the following error message:

Unable to connect to PostgreSQL server: FATAL: no pg_hba.conf entry for host "[local]", user "{username},", database "databasename,", SSL off

I've tried specifying the host as localhost, and as my domain's hostname, neither of which have worked either.

To ask this user for more information, please first login.

To submit an answer, please login.

ANSWERS

0

johnpaulb-whh2
Staff
12,339 Points
2016-06-16 8:39 pm EST
Hello,

Thank you for your question regarding issues connecting to a PostgreSQL database via PHP. We are happy to help you troubleshoot further but will need some additional information.

Can you provide the full code syntax you are using?

Please provide a link to the script.

Include any additional information to help us replicate and troubleshoot this issue.

Thank you,
John-Paul

To submit a comment on this answer, please first login.

This is the PHP I'm trying to execute:

$conn = pg_pconnect("dbname={dbname}, user={username}, password={password}, port=5432, host=localhost");

The username, password, database name are all definitely correct.
nickavv
3 Points

2016-06-18 4:42 am EST
What is the return code for the pg_connect?
ScottM
16,266 Points
Staff
2016-06-20 8:13 pm EST
Want to share this Question?

Related Articles

It looks like there are no related articles.
Would you like to ask a question about this page? If so, click the button below!
Need More Help?

Help Center Search

Current Customers

Email: support@WebHostingHub.com Ticket: Submit a Support Ticket
Call: 757-416-6627 Chat: Click To Chat Now

Ask the Community

Get help with your questions from our community of like-minded hosting users and Web Hosting Hub Staff.

Not a Customer?

Get web hosting from a company that is here to help.
}