postgresql PG::Error 服务器意外关闭连接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12796313/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PG::Error server closed the connection unexpectedly
提问by Jashwant
I am new to Ruby on rails. I've created two basic demo apps by tutorial learning by examples
我是 Ruby on rails 的新手。我通过教程创建了两个基本的演示应用程序learning by examples
and suddenly it stops working for my new sample app.
突然它停止为我的新示例应用程序工作。
I have generated a controller Pages
and two actions home
and contact
and nothing fancy.
我已经产生了控制器Pages
和两个动作home
,并contact
和没有什么花哨。
Now, I am not able to open any pages, except the default index.html rails page at localhost:3000
. The page at localhost:3000/pages/home
and localhost:3000/pages/contact
returns this error.
现在,我无法打开任何页面,除了默认的 index.html rails 页面localhost:3000
。页面localhost:3000/pages/home
并localhost:3000/pages/contact
返回此错误。
PG::Error
server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.
PG::错误
服务器意外关闭连接 这可能意味着服务器在处理请求之前或处理请求时异常终止。
and sometimes (usually when I restart postgresql),
有时(通常当我重新启动 postgresql 时),
PG::Error
server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. could not send startup packet: Broken pipe
PG::错误
服务器意外关闭连接 这可能意味着服务器在处理请求之前或处理请求时异常终止。 无法发送启动包:管道损坏
This is my stack trace
这是我的堆栈跟踪
activerecord (3.2.8) lib/active_record/connection_adapters/postgresql_adapter.rb:1213:in
initialize' activerecord (3.2.8) lib/active_record/connection_adapters/postgresql_adapter.rb:1213:in
new' activerecord (3.2.8) lib/active_record/connection_adapters/postgresql_adapter.rb:1213:inconnect' activerecord (3.2.8) lib/active_record/connection_adapters/postgresql_adapter.rb:329:in
initialize' activerecord (3.2.8) lib/active_record/connection_adapters/postgresql_adapter.rb:28:innew' activerecord (3.2.8) lib/active_record/connection_adapters/postgresql_adapter.rb:28:in
postgresql_connection' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:309:innew_connection' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:319:in
checkout_new_connection' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:241:inblock (2 levels) in checkout' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:236:in
loop' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:236:inblock in checkout' /home/jashwant/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in
mon_synchronize' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:233:incheckout' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:96:in
block in connection' /home/jashwant/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:inmon_synchronize' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:95:in
connection' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:404:inretrieve_connection' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_specification.rb:170:in
retrieve_connection' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_specification.rb:144:inconnection' activerecord (3.2.8) lib/active_record/query_cache.rb:67:in
rescue in call' activerecord (3.2.8) lib/active_record/query_cache.rb:61:incall' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in
call' actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:28:inblock in call' activesupport (3.2.8) lib/active_support/callbacks.rb:405:in
run_3261957284442330683_call_599627944998934036__callbacks' activesupport (3.2.8) lib/active_support/callbacks.rb:405:in__run_callback' activesupport (3.2.8) lib/active_support/callbacks.rb:385:in
_run_call_callbacks' activesupport (3.2.8) lib/active_support/callbacks.rb:81:inrun_callbacks' actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:27:in
call' actionpack (3.2.8) lib/action_dispatch/middleware/reloader.rb:65:incall' actionpack (3.2.8) lib/action_dispatch/middleware/remote_ip.rb:31:in
call' actionpack (3.2.8) lib/action_dispatch/middleware/debug_exceptions.rb:16:incall' actionpack (3.2.8) lib/action_dispatch/middleware/show_exceptions.rb:56:in
call' railties (3.2.8) lib/rails/rack/logger.rb:26:incall_app' railties (3.2.8) lib/rails/rack/logger.rb:16:in
call' actionpack (3.2.8) lib/action_dispatch/middleware/request_id.rb:22:incall' rack (1.4.1) lib/rack/methodoverride.rb:21:in
call' rack (1.4.1) lib/rack/runtime.rb:17:incall' activesupport (3.2.8) lib/active_support/cache/strategy/local_cache.rb:72:in
call' rack (1.4.1) lib/rack/lock.rb:15:incall' actionpack (3.2.8) lib/action_dispatch/middleware/static.rb:62:in
call' railties (3.2.8) lib/rails/engine.rb:479:incall' railties (3.2.8) lib/rails/application.rb:223:in
call' rack (1.4.1) lib/rack/content_length.rb:14:incall' railties (3.2.8) lib/rails/rack/log_tailer.rb:17:in
call' rack (1.4.1) lib/rack/handler/webrick.rb:59:inservice' /home/jashwant/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:138:in
service' /home/jashwant/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:94:inrun' /home/jashwant/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/server.rb:191:in
block in start_thread'
activerecord (3.2.8) lib/active_record/connection_adapters/postgresql_adapter.rb:1213:in
initialize' activerecord (3.2.8) lib/active_record/connection_adapters/postgresql_adapter.rb:1213:in
new'activerecord (3.2.8) lib/active_record/connection_adapters/postgresql_adapter.rb:1213:inconnect' activerecord (3.2.8) lib/active_record/connection_adapters/postgresql_adapter.rb:329:in
初始化'activerecord (3.2.8) lib/ active_record/connection_adapters/postgresql_adapter.rb:28:innew' activerecord (3.2.8) lib/active_record/connection_adapters/postgresql_adapter.rb:28:in
postgresql_connection' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:309:innew_connection' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:319:in
checkout_new_connection' activerecord (3.2.8) lib/active_adtracters/connection connection_pool.rb:241:inblock (2 levels) in checkout' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:236:in
loop' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:236:inblock in checkout' /home/jashwant/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in
mon_synchronize' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb: 233:输入checkout' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:96:in
阻止连接'/home/jashwant/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:inmon_synchronize' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:95:in
connection' activerecord (3.2.8) lib/active_record/connection_adapters /abstract/connection_pool.rb:404:inretrieve_connection'activerecordretrieve_connection' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_specification.rb:170:in
(3.2.8) lib/active_record/connection_adapters/abstract/connection_specification.rb:144:connection' activerecord (3.2.8) lib/active_record/query_cache.rb:67:in
在调用中的 救援中'activerecord (3.2.8) lib/active_record/query_cache.rb :61:incall' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in
call' actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:28:inblock in call' activesupport (3.2.8) lib/active_support/callbacks.rb:405:in
run_3261957284442330683_ call_5996279444998934036__callbacks' activecall lib/action_dispatch/middleware/callbacks.rb:28:in run_3261957284442330683_ call_599627944998934036__callbacks' activecall lib/action_dispatch/middleware/callbacks.rb:28:in run_3261957284442330627944998934036__callbacks' activecall lib/action_dispatch/middleware/callbacks.rb:__run_callback' activesupport (3.2.8) lib/active_support/callbacks.rb:385:in
3.261957284444998934036 (3.2.8) lib/active_support/callbacks.rb:81:inrun_callbacks' actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:27:in
call' actionpack (3.2.8) lib/action_dispatch/middleware/reloader.rb:65:incall' actionpack (3.2.8) lib/action_dispatch/middleware/remote_ip.rb:31:in
call' actionpack (3.2.8) lib/action_dispatch/middleware/debug_exceptions.rb:16:incall' actionpack (3.2.8) lib/action_dispatch/middleware/show_exceptions.rb:56:in
call' railties (3.2.8) lib/rails/rack/logger.rb:26:incall_app' railties (3.2.8) lib/rails/rack/logger.rb:16:in
call' actionpack (3.2.8) lib/action_dispatch/middleware/request_id.rb:22:incall' rack (1.4.1) lib/rack/methodoverride.rb:21:in
call' rack (1.4.1) lib/rack/runtime.rb: 17:incall' activesupport (3.2.8) lib/active_support/cache/strategy/local_cache.rb:72:in
call'rack (1.4.1) lib/rack/lock.rb:15:incall' actionpack (3.2.8) lib/action_dispatch/middleware/static.rb:62:in
call' railties (3.2.8) lib/rails/engine.rb:479:in call'rackcall' railties (3.2.8) lib/rails/application.rb:223:in
(1.4.1) lib /rack/content_length.rb:14:in call'rackcall' railties (3.2.8) lib/rails/rack/log_tailer.rb:17:in
(1.4.1) lib/rack/handler/webrick.rb:59:inservice' /home/jashwant/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:138:in
service' /home/jashwant/.rvm/rubies/ruby-1.9.3-p194 /lib/ruby/1.9.1/webrick/httpserver.rb:94:inrun' /home/jashwant/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/server.rb:191:in
block in start_thread'
I am not using database for now. I tried to do rake db:migrate
but it returns the same error.
我现在不使用数据库。我尝试这样做,rake db:migrate
但它返回相同的错误。
I am on Ubuntu 12.04 (as some bugs on google were related to ubuntu)
我使用的是 Ubuntu 12.04(因为 google 上的一些错误与 ubuntu 相关)
I have found similar questions on SO, but they are experiencing at some advance stage and thus involves some advance solutions.
我在 SO 上发现了类似的问题,但他们正在经历某个高级阶段,因此涉及一些高级解决方案。
采纳答案by Jashwant
Although, I am not using the database but specifying the port in configuration in database.yml
solves the problem. By default, the rails new <app_name> --database=postgresql
command does not put a port
there.
虽然,我没有使用数据库,但在配置中指定端口database.yml
解决了问题。默认情况下,该rails new <app_name> --database=postgresql
命令不会在port
那里放置。
Here's my config.
这是我的配置。
development:
adapter: postgresql
encoding: unicode
database: sample_app_development
pool: 5
port: 5433
username: myusername
password: mypassword
reconnect: true