0

当我转到默认的 rails 登录页面时,显示它没有问题,但是当我尝试显示用户时,我收到以下消息:

Started GET "/users" for 190.21.126.51 at 2013-03-27 03:27:19 +0000 
Mar 26 20:27:19 timepoints app/web.1:  PG::Error (could not connect to server: Connection refused 
Mar 26 20:27:19 timepoints app/web.1:   Is the server running on host "localhost" and accepting 
Mar 26 20:27:19 timepoints app/web.1:   TCP/IP connections on port 5432? 
Mar 26 20:27:19 timepoints app/web.1:  ): 
vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb:1206:in `initialize' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb:1206:in `new' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb:1206:in `connect' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb:329:in `initialize' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `new' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `postgresql_connection' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:309:in `new_connection' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:319:in `checkout_new_connection' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:241:in `block (2 levels) in checkout' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:236:in `loop' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:236:in `block in checkout' 
Mar 26 20:27:19 timepoints app/web.1:    /usr/local/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:233:in `checkout' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:96:in `block in connection' 
Mar 26 20:27:19 timepoints app/web.1:    /usr/local/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:95:in `connection' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:404:in `retrieve_connection' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/connection_specification.rb:168:in `retrieve_connection' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/connection_specification.rb:142:in `connection' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.6/lib/active_record/query_cache.rb:67:in `rescue in call' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.6/lib/active_record/query_cache.rb:61:in `call' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in `call' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:405:in `_run__572927131951691028__call__675318756725154442__callbacks' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:405:in `__run_callback' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:385:in `_run_call_callbacks' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.6/lib/active_support/callbacks.rb:81:in `run_callbacks' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_dispatch/middleware/callbacks.rb:27:in `call' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_dispatch/middleware/remote_ip.rb:31:in `call' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/rack/logger.rb:26:in `call_app' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/rack/logger.rb:16:in `call' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_dispatch/middleware/request_id.rb:22:in `call' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/methodoverride.rb:21:in `call' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/runtime.rb:17:in `call' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.6/lib/active_support/cache/strategy/local_cache.rb:72:in `call' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/lock.rb:15:in `call' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.6/lib/action_dispatch/middleware/static.rb:62:in `call' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:245:in `fetch' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:185:in `lookup' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:66:in `call!' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/engine.rb:479:in `call' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/application.rb:220:in `call' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/content_length.rb:14:in `call' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/railties-3.2.6/lib/rails/rack/log_tailer.rb:17:in `call' 
Mar 26 20:27:19 timepoints app/web.1:    vendor/bundle/ruby/1.9.1/gems/rack-1.4.5/lib/rack/handler/webrick.rb:59:in `service' 
Mar 26 20:27:19 timepoints app/web.1:    /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service' 
Mar 26 20:27:19 timepoints app/web.1:    /usr/local/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run' 
Mar 26 20:27:19 timepoints app/web.1:    /usr/local/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread' 
Mar 26 20:27:19 timepoints heroku/router:  at=info method=GET path=/users host=timepoints.herokuapp.com fwd="190.21.126.51" dyno=web.1 connect=2ms service=8ms status=500 bytes=643 
Mar 26 20:27:20 timepoints heroku/router:  at=info method=GET path=/favicon.ico host=timepoints.herokuapp.com fwd="190.21.126.51" dyno=web.1 connect=20ms service=13ms status=304 bytes=0 

我已经设置了我的application.rbproduction.rb

config.assets.initialize_on_precompile = false

我确实heroku run rake db:setup按照其他帖子中的建议运行,并且还尝试了db:migratedb:reset

我已经检查过heroku config,我可以看到DATABASE_URL已经设置为HEROKU_POSTGRESQL_OLIVE_URL

我还删除了该应用程序并部署到一个新应用程序,但同样的问题不断发生。

Gemfile的有以下几点:

group :production do
  gem 'thin'
  gem 'activerecord-postgresql-adapter'
end

我正在使用 Rails 3.2.6 和 Ruby 1.9.2


更新: 我刚刚升级到 Rails 4.0.0 和 Ruby 2.0.0,但我一直收到同样的错误


更新 2: 我已将我的应用程序降级到 rails 3.1.0 和 ruby​​ 1.9.3 并且已经解决了一些错误。我仍然有连接到服务器的问题。


更新 3: 我联系了 Heroku,他们帮助我解决了问题。这是一个与我的开发数据库的连接,我在一些帮助文件中调用了该文件,该文件破坏了生产中的连接。删除解决了问题

4

2 回答 2

0

我已经将我的应用程序降级到 rails 3.1.0 和 ruby​​ 1.9.3 并且已经解决了一些错误。

然后我联系了 Heroku,他们帮我解决了这个问题。这是一个与我的开发数据库的连接,我在一些帮助文件中调用了该文件,该文件破坏了生产中的连接。删除解决了问题

于 2013-03-28T03:14:48.570 回答
0

你应该使用gem 'pg'

group :production do
  gem 'pg'
end

然后应该自动建立连接,假设您DATABASE_URL指向一个有效的数据库。

您还应该确认RAILS_ENV(也许还有RACK_ENV)设置为productionin $ heroku config

您的 Procfile 是否提及RAILS_ENVor RACK_ENV

于 2013-03-27T13:52:29.260 回答