0

So I'm working on a ruby on rails project with a team, and they use ubuntu through vagrant to host the database (in postgresql), so all the rails commands are still executed from the host machine (windows).

Basically, I'm having troubles connecting the two ends, everytime I try to go on any page, it tells me

PG::ConnectionBad
could not connect to server: Cannot assign requested address (0x00002741/10049) Is the server running on host "0.0.0.0" and accepting TCP/IP connections on port 6543?

The Vagrantfile forwards the port 6543 to 5432

  config.vm.network :forwarded_port, guest: 5432, host: 6543

and when I ssh into vagrant, it does indeed seem to be listening on that port:

Proto Recv-Q Send-Q Local Address           Foreign Address         State    
tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN

I don't know what's not working, I've even tried disabling the firewall to check whether that was the issue, but it wasn't.

I welcome any help that can be offered. Thank you

EDIT: After reading this, I looked at my pg_hba.conf file, but it looks like it's allowing all connections:

# "local" is for Unix domain socket connections only
local   all             all                                  trust
# IPv4 local connections:
host    all             all             0.0.0.0/0            trust
# IPv6 local connections:
host    all             all             ::/0                 trust
Dominus
  • 808
  • 11
  • 25
  • I think You need to specify the 'host' key in your database.yml file and put the ip of the vagrant VM as the value of that key. – Rada Bogdan Jun 20 '17 at 20:50
  • And the 'port' key in same file with value 6543. Since that is the port on which Connects to the 5432 port from VM – Rada Bogdan Jun 20 '17 at 20:51

0 Answers0