agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Chris <cglenstark@apple.com>
To: pgsql-sql@postgresql.org
Subject: Re: Re: Connection to database failed: FATAL: no pg_hba.conf entry for host
Date: Wed, 13 Apr 2016 07:50:51 -0700
Message-ID: <570E5CCB.502@aklaver.com> (raw)
In-Reply-To: <1460503188702-5898337.post@n5.nabble.com>
References: <1460413886714-5898099.post@n5.nabble.com>
	<570D7D2C.8010404@aklaver.com>
	<1460503188702-5898337.post@n5.nabble.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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-tp589...
> Sent from the PostgreSQL - sql mailing list archive at Nabble.com.
>
>


-- 
Adrian Klaver
adrian.klaver@aklaver.com


-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



view thread (6+ messages)  latest in thread

Message-ID: <570E5CCB.502@aklaver.com>
Permalink:  ../570E5CCB.502@aklaver.com/
Also on:    postgresql.org/message-id/570E5CCB.502@aklaver.com

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: adrian.klaver@aklaver.com, cglenstark@apple.com
  Subject: Re: Re: Connection to database failed: FATAL: no pg_hba.conf entry for host
  In-Reply-To: <570E5CCB.502@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox