Trouble connecting to Postgresql database in Vagrant guest box with Induction from host machine?

末鹿安然 提交于 2019-12-01 13:12:08

问题


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"

回答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




回答2:


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



来源:https://stackoverflow.com/questions/18725855/trouble-connecting-to-postgresql-database-in-vagrant-guest-box-with-induction-fr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!