Tuesday, September 02, 2014

Exposing PostgreSQL on vagrant to host OS

I've been working with vagrant lately on a Ruby project and I wanted to the ability to view the PostgreSQL database on the vagrant image through DbVisualizer on my OS X system. This is quite easy to set up in PostgreSQL and vagrant.
  1. Add a port forwarding entry to your Vagrantfile: config.vm.network "forwarded_port", guest: 5432, host: 15432. I'm using Vagrant 1.6.3 here. Start/restart your Vagrant image.
  2. Edit the pg_hba.conf file on the vagrant image. This file may reside in different areas; ours was in /etc/postgresql/9.1/main/. Change the IPv4 local connections entry from...

    host    all             all             127.0.0.1/32            trust
    

    to

    host    all             all             0.0.0.0/0               trust
    

  3. Restart PostgreSQL on the vagrant image: sudo service postgresql restart
  4. Configure your database tool to connect to localhost, port 15432.
You should be able to connect to your Vagrant PostgreSQL databases now.

8 comments:

  1. What you can do. That's what I do not and have not ever thought of. friv 5

    ReplyDelete
  2. Great and useful article. Creating content regularly is very tough. Your points are motivated me to move on.


    SEO Company in Chennai

    ReplyDelete

  3. This information is impressive; I am inspired with your post writing style & how continuously you describe this topic.

    Payday loans in Alabama
    Title loans in South Carolina

    ReplyDelete

  4. Its a wonderful post and very helpful, thanks for all this information. You are including better information regarding this topic in an effective way.Thank you so much

    Installment Loans Near Me
    Title loans Near Me
    Cash Advances Near Me

    ReplyDelete