PG ::错误服务器意外关闭了连接

Jas*_*ant 6 ruby postgresql ruby-on-rails

我是Ruby on rails的新手.我已经通过教程创建了两个基本的演示应用程序learning by examples

突然它停止为我的新示例应用程序工作.

我已经生成了一个控制器Pages和两个动作home,contact并没有什么花哨的.

现在,我无法打开任何页面,除了默认的index.html rails页面localhost:3000.页面位于localhost:3000/pages/homelocalhost:3000/pages/contact返回此错误.

PG ::错误

服务器意外关闭连接这可能意味着服务器在处理请求之前或处理时异常终止.

有时(通常当我重新启动postgresql时),

PG ::错误

服务器意外关闭连接这可能意味着服务器在处理请求之前或处理时异常终止. 无法发送启动数据包:管道损坏

这是我的堆栈跟踪

activerecord(3.2.8)lib/active_record/connection_adapters/postgresql_adapter.rb:1213:在 initialize' activerecord (3.2.8) lib/active_record/connection_adapters/postgresql_adapter.rb:1213:in 新的'activerecord(3.2.8)lib/active_record/connection_adapters/postgresql_adapter.rb:1213: connect' 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:在 new' 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:in new_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:in block (2 levels) in checkout' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:236:in 循环'activerecord(3.2.8)lib/active_record/connection_adapters/abstract/connection_pool.rb:236:在 block 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:in mon_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:在 retrieve_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/connecti on_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:在call' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in 调用'actionpack(3.2.8)lib/action_dispatch/middleware/callbacks.rb中: 28:block in call' activesupport (3.2.8) lib/active_support/callbacks.rb:405:in 运行 _3261957284442330683_ 调用 _599627944998934036__callbacks'activesupport(3.2.8)lib/active_support/callbacks.rb:405:在 __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:在 run_callbacks' actionpack (3.2.8) lib/action_dispatch/middleware/callbacks.rb:27:in调用'actionpack(3.2. 8)lib/action_dispatch/middleware/reloader.rb:65:在call' actionpack (3.2.8) lib/action_dispatch/middleware/remote_ip.rb:31:in 调用'actionpack(3.2.8)lib/action_dispatch/middleware/debug_exceptions.rb:16:在call' actionpack (3.2.8) lib/action_dispatch/middleware/show_exceptions.rb:56:in调用'railties(3.2.8)lib/rails/rack/logger.rb:26:在call_app' railties (3.2.8) lib/rails/rack/logger.rb:16:in呼叫'ActionPack的(3.2.8)LIB/action_dispatch /中间件/ request_id.rb:22:在call' rack (1.4.1) lib/rack/methodoverride.rb:21:in呼叫'机架(1.4.1)LIB /齿条/ runtime.rb:17:在call' activesupport (3.2.8) lib/active_support/cache/strategy/local_cache.rb:72:in呼叫"机架(1.4.1)lib/rack/lock.rb:15:在call' actionpack (3.2.8) lib/action_dispatch/middleware/static.rb:62:in调用'railties(3.2.8)lib/rails/engine.rb:479:在call' railties (3.2.8) lib/rails/application.rb:223:in调用'rack(1.4.1)lib/rack/content_length.rb :14:在call' railties (3.2.8) lib/rails/rack/log_tailer.rb:17:in电话'机架(1.4.1)lib/rack/handler/webrick.rb:59:在service' /home/jashwant/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:138:in 服务'/home/jashwant/.rvm/rubies/ruby-1.9.3-p194/lib/ruby /1.9.1/webrick/httpserver.rb:94:in start_thread中的 run' /home/jashwant/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/server.rb:191:in 块'

我现在不使用数据库.我试着做,rake db:migrate但它返回相同的错误.

我在Ubuntu 12.04上(因为google上的一些bug与ubuntu有关)

我在SO上发现了类似的问题,但是他们正在经历一些提前阶段,因此涉及一些先进的解决方案.

Jas*_*ant 5

虽然,我没有使用数据库,但在配置中指定端口database.yml解决了问题。默认情况下,该rails new <app_name> --database=postgresql命令不会在port那里放置。

这是我的配置。

development:
  adapter: postgresql
  encoding: unicode
  database: sample_app_development
  pool: 5  
  port: 5433
  username: myusername
  password: mypassword
  reconnect: true
Run Code Online (Sandbox Code Playgroud)