0

I have been working on this for awhile now...... This question has been asked a few times before (links below).

Another Similar Question with PGSQL, Vagrant, Induction

Same question except with pgAdmin

Connecting to Vagrant PGSQL from Host

I've read the Vagrant documentation for Networking and for enter link description here. Also, I've tried to resolve my problem with this useful link http://www.revsys.com/writings/postgresql/errors.html but it still not working.

The error that I'm experiencing is this

Is the server running on host "192.168.50.4" and accepting
TCP/IP connections on port 5432?

What I have is a Mac OSX with a rails application and I have a vagrant environment that is running PGSQL 9.2.6. The database on vagrant and on my Mac OSX are the same database with the exact users, privileges, and schema.

What I want to do is to get my rails app to connect to the 9.2.6 PGSQL on vagrant.

Here is a snippet of my database.yml file for my rails app:

DB_HOST = "192.168.50.4" #This ip is taken from vagrant example
DB_NAME = "testing"
DB_USERNAME = "postgres_user"
DB_PASSWORD = "password"
DB_PORT = "5432"

My Vagrantfile looks like this:

Vagrant.configure(2) do |config|
  config.vm.box = "ubuntu/trusty64"
  config.vm.network "private_network", ip: "192.168.50.4"
end

I have postgresql running as shown with pas aux | grep postgres

What seems to be causing the problem has to be either the pg_hba.conf file or the postgresql.conf file.

I've set my listen_address to '*'

listen_address = '*'
port = 5432
max_connections = 100

From the other stack overflow questions that seemed to be the problem but it still doesn't work for me.

Here is my pg_hba.conf

local   all             postgres                                trust

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                    trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# Connecting to postgresql on vagrant from ohloh and ohloh-ui
host    openhub_testing  all          192.168.50.4/32        trust
# IPv6 local connections:
host    all             all             ::1/128                 md5

Although I do specify a user and password in my database.yml I regardless put everything on trust because I was having problems connecting to pgsql from vagrant.

Can anyone point out what I haven't tried yet. I'm out of options to try. Much appreciated.

Community
  • 1
  • 1
Dan Rubio
  • 4,709
  • 10
  • 49
  • 106

1 Answers1

0

The solution was indeed the pg_hba.conf file. Instead of 192.168.50.4/32, I needed to add 192.168.50.1/32.

Dan Rubio
  • 4,709
  • 10
  • 49
  • 106