Re: "Failed to connect to Postgres database"

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Marco Ippolito <ippolito(dot)marco(at)gmail(dot)com>
Cc: Martin Gainty <mgainty(at)hotmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: "Failed to connect to Postgres database"
Date: 2019-09-26 18:53:49
Message-ID: db155089-f552-f1c3-5079-53dee03eb7be@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 9/26/19 10:10 AM, Marco Ippolito wrote:
> Hi Adrian,
>
> I removed the previous fabmentdb and created a new one whose owner is
> postgres:
>
> (base) postgres(at)pc:/usr/local/pgsql$ psql --cluster 11/fabmnet
> psql (11.5 (Ubuntu 11.5-1.pgdg18.04+1))
> Type "help" for help.
>
> postgres=# \l
>                               List of databases
>    Name    |  Owner   | Encoding | Collate |  Ctype  |   Access privileges
> -----------+----------+----------+---------+---------+-----------------------
>  fabmnetdb | postgres | UTF8     | C.UTF-8 | C.UTF-8 |
>  postgres  | postgres | UTF8     | C.UTF-8 | C.UTF-8 |
>  template0 | postgres | UTF8     | C.UTF-8 | C.UTF-8 | =c/postgres
>      +
>            |          |          |         |         |
> postgres=CTc/postgres
>  template1 | postgres | UTF8     | C.UTF-8 | C.UTF-8 | =c/postgres
>      +
>            |          |          |         |         |
> postgres=CTc/postgres
> (4 rows)
>
> postgres=#
>
> _First objective: enable and make it working ssl connection for fabmnetd_b :
>
> Following the indications found here:
> https://vibhork.blogspot.com/2011/07/how-to-enable-ssl-in-postgresqlppas.html
> I created .pem and .req files in /var/lib/postgresql/11/fabmnet/  where,
> according to nano /etc/postgresql/11/fabmnet/postgresql.conf, the data
> folder is located:
>     data_directory = '/var/lib/postgresql/11/fabmnet'
>     ssl = on
>
>
> (base) postgres(at)pc:/var/lib/postgresql/11/fabmnet$ chmod 600 privkey.pem
> (base) postgres(at)pc:/var/lib/postgresql/11/fabmnet$ chmod 600 cert.req
>
> But now, testing the ssl connection :
>
> (base) marco(at)pc:/usr/local/pgsql$ psql -h 127.0.0.1 -d fabmnetdb -U postgres
> Password for user postgres:
> psql: FATAL:  database "fabmnetdb" does not exist
>
> What am I missing?

My suspicion is that you have more then once instance of Postgres
running. Partly because of this:

psql --cluster 11/fabmnet

and then later:

psql -h 127.0.0.1 -d fabmnetdb -U postgres

Not sure they are pointing at the same thing.

At command line what does:

ps ax | grep post

show.

> Thanks again for your kind help.
> Marco
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2019-09-26 19:02:31 Re: row_to_json white space
Previous Message Adrian Klaver 2019-09-26 18:49:10 Re: row_to_json white space