Re: Re: Connection to database failed: FATAL: no pg_hba.conf entry for host - Mailing list pgsql-sql
| From | Adrian Klaver |
|---|---|
| Subject | Re: Re: Connection to database failed: FATAL: no pg_hba.conf entry for host |
| Date | |
| Msg-id | 570E5CCB.502@aklaver.com Whole thread Raw |
| In response to | Re: Connection to database failed: FATAL: no pg_hba.conf entry for host (Chris <cglenstark@apple.com>) |
| Responses |
Re: Connection to database failed: FATAL: no pg_hba.conf entry for
host
|
| List | pgsql-sql |
On 04/12/2016 04:19 PM, Chris wrote:
> 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
So is it possible to show the complete pg_hba.conf?
>
> 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] = [port cStringUsingEncoding: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.
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com