Psql: Could not connect to server

I am pretty new to linux systems and DBs so having a difficulty in accessing musicbrainz database using VM. I tried my best to resolve this issue but could not find a way.

When I try “psql -h localhost -U musicbrainz -p 5432”

I got a following message:

"Could not connect to server: No route to host
Is the server running on host “localhost (127.0.0.1) and accepting TCP/IP connections on port 5432?”

For your information, I am using virtualbox (5.1.14) in Windows 8. (PostgreSQL (9.5) installed in a server image.)
I could find two “pg_hba.conf” files in different directories so set both of them to include
"host all all 0.0.0.0/0 trust
"host all all ::0/0 trust"
I also edit postgresql.conf: listen_addresses = ‘*’

I tried other network settings in the virtualbox not limited to NAT and also changed “localhost” to other IP address shown in ifconfig, when I execute “psql -h localhost -U musicbrainz -p 5432”.
Using port 15432 instead of 5432 did not help either.

Thanks in advance for helping me.

1 Like

Log into VM and edit docker-compose.yml following patch from this previous topic:

1 Like

@Yvanz Thank you. Although I read the article you attached I don’t know which part to be edited.

Theses are some information given, when I open docker-compose.yml
postgresql:
expose:

  • "5432"
    musicbrainz:
    ports:
  • "5000:5000"
    expose:
  • "5000"
    search
    expose:
  • “8080”

I also looked at postgres.env but nothing special was there.

After this section

expose: 
- "5432"

Add

ports:
 - "5432:5432"

Make sure you get the indentation exactly right. It should look the same as the line with expose and the line after. ports should have 2 spaces in front of it, and the second line should have 3 spaces.

After you have made the changes, run the reset-containers command as described in the documentation:

1 Like

@alastairp Thanks. It works well!