【发布时间】:2012-12-22 21:35:02
【问题描述】:
每次运行 Rails 应用程序时都会出现此错误(它无法连接到我的本地 Postgresql)
/Users/leonardo/.rvm/gems/ruby-1.9.3-p362/gems/activerecord-3.2.11/lib/
active_record/connection_adapters/postgresql_adapter.rb:1208:in `initialize':
could not connect to server: No such file or directory (PG::Error)
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
我正在使用Postgres.app,它运行正常。
如果我跑步
$ psql
我可以正常登录到 Postgresql 控制台。
$ which psql
/Applications/Postgres.app/Contents/MacOS/bin/psql
Gemfile
source 'https://rubygems.org'
ruby "1.9.3"
gem 'rails', '3.2.11'
gem "pg"
database.yml
development:
adapter: postgresql
encoding: unicode
username: leonardo
password:
database: zapping
port: 5432
Postgresql(控制台)
$ psql
leonardo=# \l
【问题讨论】:
-
您可以尝试将
host: localhost添加到您的database.yml 吗? (基于那个答案:stackoverflow.com/a/10793186/919641) -
如果您将其添加到“答案”中,我将标记为已接受
标签: ruby-on-rails postgresql rails-postgresql pg