[英]Rails cannot establish a Postgres connection
I'm trying to run a previously working Rails 3 app with this configuration: 我正在尝试使用此配置运行以前运行的Rails 3应用程序:
development:
adapter: postgres-pr
#encoding: utf-8
host: localhost
port: 5432
database: name
username: user-name
password: user-password
#pool: 5
#timeout: 5000
#reconnect: true
It's the first time I use Postgres, so my configuration may be off. 这是我第一次使用Postgres,所以我的配置可能会关闭。 PGAdmin works, though.
但是,PGAdmin可以工作。
pg_hba.conf has the following: pg_hba.conf具有以下内容:
local all postgres peer
local all user-name password
host all user-name 127.0.0.1/32 password
host all user-name ::1/128 password
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
(I tried other configurations, it doesn't seem to change things). (我试过其他配置,它似乎没有改变的东西)。
I get the error ActiveRecord::ConnectionNotEstablished
whenever I try to load any page. 每当我尝试加载任何页面时,我都会收到错误
ActiveRecord::ConnectionNotEstablished
。 The network trace reveals the following: 网络跟踪显示以下内容:
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 9
setsockopt(9, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
bind(9, {sa_family=AF_INET, sin_port=htons(3000), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
listen(9, 100) = 0
accept(9, {sa_family=AF_INET, sin_port=htons(50500), sin_addr=inet_addr("127.0.0.1")}, [16]) = 10
setsockopt(10, SOL_TCP, TCP_NODELAY, [1], 4) = 0
accept(9, 0xbf937aec, [16]) = -1 EAGAIN (Resource temporarily unavailable)
getpeername(10, {sa_family=AF_INET, sin_port=htons(50500), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
network,open
trace doesn't have the port 5432 either. network,open
跟踪也没有端口5432。
I can't see the port that I wanted here, am I setting it in the wrong way? 我看不到我想要的端口,我是以错误的方式设置的吗? What else could be the problem here?
还有什么可能是这里的问题?
This is my 'database.yml', not using 'port' at all, maybe it can hint you in the right direction: 这是我的'database.yml',根本不使用'port',也许它可以暗示你正确的方向:
# PostgreSQL. Versions 7.4 and 8.x are supported.
#
# Install the pg driver:
# gem install pg
# On Mac OS X with macports:
# gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
# On Windows:
# gem install pg
# Choose the win32 build.
# Install PostgreSQL and put its /bin directory on your path.
#
# Configure Using Gemfile
# gem 'pg'
#
development:
adapter: postgresql
encoding: unicode
database: name
pool: 5
username: name
password:
# Connect on a TCP socket. Omitted by default since the client uses a
# domain socket that doesn't need configuration. Windows does not have
# domain sockets, so uncomment these lines.
#host: localhost
#port: 5432
# Schema search path. The server defaults to $user,public
#schema_search_path: myapp,sharedapp,public
# Minimum log levels, in increasing order:
# debug5, debug4, debug3, debug2, debug1,
# log, notice, warning, error, fatal, and panic
# The server defaults to notice.
#min_messages: warning
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test: &test
adapter: postgresql
encoding: unicode
database: name
pool: 5
username: name
password:
min_messages: warning
production:
adapter: postgresql
encoding: unicode
database: name
pool: 5
username: name
password:
cucumber:
<<: *test
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.