Connecting to local PostgreSQL started within docker

Hi all,

I set up a local installation with docker [GitHub - metabrainz/musicbrainz-docker: Docker Compose project for the MusicBrainz Server with replication, search, and development setup] and like to connect the PostgreSQL-Server obviously running. I found some credentials in the file

./build/musicbrainz/DBDefs.pm

But even the user musicbrainz mentioned there is not connected!

Screenshot_20200901_145540

Ends up with

Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections. [SQL State=08001]

Changing host from localhost to 127.0.0.1 doesn’t make it work neither. Can someone tell me how to connect to PostgreSQL please?

Many thanx

Chris

1 Like

One possible reason could be: https://github.com/metabrainz/musicbrainz-docker#publish-ports-of-all-services

2 Likes

Thank you. Almost perfect, now the test-user can connect. How do I get superuser postgres connected? I used login-name postgres and database musicbrainz_db but got The server requested password-based authentication, but no password was provided. [SQL State=08004] on an empty password and FATAL: password authentication failed for user "postgres" [SQL State=28P01] on password postgres.

You can try this one:

3 Likes

Works perfectly fine, thank you!

musicbrainz-docker> psql -h 127.0.0.1 -U musicbrainz -W
Passwort: 
psql (12.4)
Geben Sie »help« für Hilfe ein.

musicbrainz=# \l
                                       Liste der Datenbanken
      Name      | EigentĂĽmer  | Kodierung | Sortierfolge | Zeichentyp |     Zugriffsprivilegien     
----------------+-------------+-----------+--------------+------------+-----------------------------
 musicbrainz    | musicbrainz | UTF8      | en_US.utf8   | en_US.utf8 | 
 musicbrainz_db | musicbrainz | UTF8      | C            | C          | 
 postgres       | musicbrainz | UTF8      | en_US.utf8   | en_US.utf8 | 
 template0      | musicbrainz | UTF8      | en_US.utf8   | en_US.utf8 | =c/musicbrainz             +
                |             |           |              |            | musicbrainz=CTc/musicbrainz
 template1      | musicbrainz | UTF8      | en_US.utf8   | en_US.utf8 | =c/musicbrainz             +
                |             |           |              |            | musicbrainz=CTc/musicbrainz
(5 Zeilen)
3 Likes

After an update everything seemed fine …

sudo docker-compose up -d
musicbrainz-docker_db_1 is up-to-date
musicbrainz-docker_redis_1 is up-to-date
musicbrainz-docker_mq_1 is up-to-date
musicbrainz-docker_search_1 is up-to-date
Recreating musicbrainz-docker_musicbrainz_1 ... done
Starting musicbrainz-docker_indexer_1       ... done

But the connection to the PostgreSQL-server within docker seems broken …

musicbrainz-docker> psql -h 127.0.0.1 -U musicbrainz -W
Passwort: 
psql: Fehler: konnte nicht mit dem Server verbinden: Verbindungsaufbau abgelehnt
        Läuft der Server auf dem Host »127.0.0.1« und akzeptiert er
        TCP/IP-Verbindungen auf Port 5432?
musicbrainz-docker> psql -h localhost -U musicbrainz -W
Passwort: 
psql: Fehler: konnte nicht mit dem Server verbinden: Verbindungsaufbau abgelehnt
        Läuft der Server auf dem Host »localhost« (::1) und akzeptiert er
        TCP/IP-Verbindungen auf Port 5432?

How and where can I search for this fails’ cause?

RTFM Publish ports of all services
Thank you form great software and documentation!

2 Likes