0

I'm trying to connect to my PostgreSQL database which is inside of a guest machine (using Vagrant and VirtualBox).

I'm trying to connect to it with Induction, but I am getting an error saying:

Connection Error
Could not connect to server: Permission denied
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.1234"

I have Vagrant doing a port forward to port 1234 on my host machine.

My settings for the Induction connection are:

Adapter: postgres
Host Name: 127.0.0.1
Username: vagrant
Password: [i don't have a password for the vagrant user for postgres so leaving empty]
Port: 1234
Database: development

The development database was created by Rails using rake db:create:all and I know that it works because I see it from the Rails db console.

In my postgresql.conf file, I have set listen_addresses to '*' to listen to external machines also.

What am I doing wrong?

EDIT (adding my pg_hba.conf):

# Database administrative login by Unix domain socket
local   all             postgres                                peer

# 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            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5

EDIT (this is the error that shows from the Induction app when trying to connect)

could not connect to server: Permission denied
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.1234"
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Hung Luu
  • 1,113
  • 19
  • 35

2 Answers2

1

check file pg_hba.conf looks like require allow connection most easy and lesss secure set 'trust' (everyone can use your postgresql) http://www.postgresql.org/docs/9.2/static/auth-pg-hba-conf.html

Pronix
  • 938
  • 8
  • 8
  • hi user647622 - i just added my pg_hba.conf configuration, i changed the local connection to trust METHOD. but it still doesn't work. – Hung Luu Sep 11 '13 at 01:03
  • hi @user647622 please see my edit for the error returned when trying to connect with Induction – Hung Luu Oct 07 '13 at 18:26
  • if i correct understand you want connect from your host to database on virtual machine. if true - require change ip from 127.0.0.1 to vm's ip. and add to pg_hba string `host all all md5` – Pronix Oct 07 '13 at 19:00
  • so in the pg_hba.conf should it be host all all VM ADDRESS md5? – Hung Luu Oct 07 '13 at 23:03
  • or should it just be host all all [leave address blank] md5 i apologize for all of the questions. i'm not very familiar with postgres or VMs @user647622 – Hung Luu Oct 07 '13 at 23:42
  • host all all [leave address blank] md5 – Pronix Oct 08 '13 at 18:06
  • I just tried host all all [leave address blank] md5 and it doesn't work. It also breaks my ability to connect to the Postgres from my Rails App (sitting in the guest machine) which I access from my host machine's browser – Hung Luu Oct 08 '13 at 18:51
  • amazing issue description :) – Pronix Oct 08 '13 at 19:09
  • Also check what the postgresql.conf says. – Chris Travers Nov 13 '13 at 13:57
0

I've seen that connection error when the PostgreSQL service is not running.

Check the status of the PostgreSQL service: sudo service postgresql status

Start the service: sudo service postgresql status

Alpha Codemonkey
  • 3,242
  • 21
  • 26