Re: Connection to database failed: FATAL: no pg_hba.conf entry for host - Mailing list pgsql-sql

From Chris
Subject Re: Connection to database failed: FATAL: no pg_hba.conf entry for host
Date
Msg-id 1460503188702-5898337.post@n5.nabble.com
Whole thread Raw
In response to Re: Connection to database failed: FATAL: no pg_hba.conf entry for host  (Adrian Klaver <adrian.klaver@aklaver.com>)
Responses Re: Re: Connection to database failed: FATAL: no pg_hba.conf entry for host  (Adrian Klaver <adrian.klaver@aklaver.com>)
List pgsql-sql
Thanks for your reply Adrian.

I thought about the port. The server name is correct, and I provided the
default port 5432 in place of the empty string. And it still did not work.
We are using the default port settings for both SSL and non-SSL connections.

I also tried using the PQconnectdbParams (see below) in place of
PQconnectdb. Using exactly the same code as in the Open Source with few
minor modifications. Connecting using this method still fails with the
following error message...

Connection to database failed: FATAL:  no pg_hba.conf entry for host
"12.224.126.19", user "james", database "database", SSL off

Now I am trying to figure out why psql works with the code below, but the
Application that I am creating does not. I checked that the encoding
NSASCIIStringEncoding is converted properly, I even hard coded the
parameters to no avail. Would there be any compiler setting I need to set in
XCode? 

I am building on Yosemite. The application is connecting properly on several
Mac computers running both Yosemite and El Capitan. We only have three
computers where the application fails to connect, each being either Yosemite
or El Capitan. Each have some type of SSL network connection, otherwise spql
would not succeed.

Strange part about this problem is that not every computer is having this
connection issue, and the computers that are failing, work perfectly fine
with psql and pgAdmin. 
   bool notty = (!isatty(fileno(stdin)) || !isatty(fileno(stdout)));      #define PARAMS_ARRAY_SIZE    7   const char
**keywords= malloc(PARAMS_ARRAY_SIZE * sizeof(*keywords));   const char **values = malloc(PARAMS_ARRAY_SIZE *
sizeof(*values));     keywords[0] = "host";   values[0] = [host cStringUsingEncoding:NSASCIIStringEncoding];
keywords[1]= "port";      if ([port isEqualToString:@""]) {       values[1] = "5432";   }   else{       values[1] =
[portcStringUsingEncoding:NSASCIIStringEncoding];   }   keywords[2] = "user";   values[2] = [user
cStringUsingEncoding:NSASCIIStringEncoding];  keywords[3] = "password";   values[3] = [pass
cStringUsingEncoding:NSASCIIStringEncoding];  keywords[4] = "dbname";   values[4] = [db
cStringUsingEncoding:NSASCIIStringEncoding];  keywords[5] = "client_encoding";   values[5] = (notty ||
getenv("PGCLIENTENCODING"))? NULL : "auto";   keywords[6] = NULL;   values[6] = NULL;      //new_pass = false;   conn =
PQconnectdbParams(keywords,values, true);   free(keywords);   free(values);
 



--
View this message in context:
http://postgresql.nabble.com/Connection-to-database-failed-FATAL-no-pg-hba-conf-entry-for-host-tp5898099p5898337.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.



pgsql-sql by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: Connection to database failed: FATAL: no pg_hba.conf entry for host
Next
From: Dhaval Patel
Date:
Subject: Re: Connection to database failed: FATAL: no pg_hba.conf entry for host