title: PG::Error server closed the connection unexpectedly
body: <p>I am new to Ruby on rails. I've created two basic demo apps by tutorial <code>learning by examples</code></p>
  
  <p>and suddenly it stops working for my new sample app.</p>
  
  <p>I have generated a controller <code>Pages</code> and two actions <code>home</code> and <code>contact</code> and nothing fancy.</p>
  
  <p>Now, I am not able to open any pages, except the default index.html rails page at <code>localhost:3000</code>.  The page at <code>localhost:3000/pages/home</code> and <code>localhost:3000/pages/contact</code> returns this error.</p>
  
  <blockquote>
    <p>PG::Error</p>
    
    <p>server closed the connection unexpectedly     This probably means the
    server terminated abnormally  before or while processing the request.</p>
  </blockquote>
  
  <p>and sometimes (usually when I restart postgresql),</p>
  
  <blockquote>
    <p>PG::Error</p>
    
    <p>server closed the connection unexpectedly     This probably means the
    server terminated abnormally  before or while processing the request.
            <strong>could not send startup packet: Broken pipe</strong></p>
  </blockquote>
  
  <p>This is my stack trace</p>
  
  <blockquote>
    <p>activerecord (3.2.8)
    lib/active_record/connection_adapters/postgresql_adapter.rb:1213:in
    <code>initialize' activerecord (3.2.8)
    lib/active_record/connection_adapters/postgresql_adapter.rb:1213:in
    </code>new' activerecord (3.2.8)
    lib/active_record/connection_adapters/postgresql_adapter.rb:1213:in
    <code>connect' activerecord (3.2.8)
    lib/active_record/connection_adapters/postgresql_adapter.rb:329:in
    </code>initialize' activerecord (3.2.8)
    lib/active_record/connection_adapters/postgresql_adapter.rb:28:in
    <code>new' activerecord (3.2.8)
    lib/active_record/connection_adapters/postgresql_adapter.rb:28:in
    </code>postgresql_connection' activerecord (3.2.8)
    lib/active_record/connection_adapters/abstract/connection_pool.rb:309:in
    <code>new_connection' activerecord (3.2.8)
    lib/active_record/connection_adapters/abstract/connection_pool.rb:319:in
    </code>checkout_new_connection' activerecord (3.2.8)
    lib/active_record/connection_adapters/abstract/connection_pool.rb:241:in
    <code>block (2 levels) in checkout' activerecord (3.2.8)
    lib/active_record/connection_adapters/abstract/connection_pool.rb:236:in
    </code>loop' activerecord (3.2.8)
    lib/active_record/connection_adapters/abstract/connection_pool.rb:236:in
    <code>block in checkout'
    /home/jashwant/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in
    </code>mon_synchronize' activerecord (3.2.8)
    lib/active_record/connection_adapters/abstract/connection_pool.rb:233:in
    <code>checkout' activerecord (3.2.8)
    lib/active_record/connection_adapters/abstract/connection_pool.rb:96:in
    </code>block in connection'
    /home/jashwant/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in
    <code>mon_synchronize' activerecord (3.2.8)
    lib/active_record/connection_adapters/abstract/connection_pool.rb:95:in
    </code>connection' activerecord (3.2.8)
    lib/active_record/connection_adapters/abstract/connection_pool.rb:404:in
    <code>retrieve_connection' activerecord (3.2.8)
    lib/active_record/connection_adapters/abstract/connection_specification.rb:170:in
    </code>retrieve_connection' activerecord (3.2.8)
    lib/active_record/connection_adapters/abstract/connection_specification.rb:144:in
    <code>connection' activerecord (3.2.8)
    lib/active_record/query_cache.rb:67:in</code>rescue in call' activerecord
    (3.2.8) lib/active_record/query_cache.rb:61:in <code>call' activerecord
    (3.2.8)
    lib/active_record/connection_adapters/abstract/connection_pool.rb:473:in
    </code>call' actionpack (3.2.8)
    lib/action_dispatch/middleware/callbacks.rb:28:in <code>block in call'
    activesupport (3.2.8) lib/active_support/callbacks.rb:405:in
    </code><em>run</em>_3261957284442330683_<em>call</em>_599627944998934036__callbacks'
    activesupport (3.2.8) lib/active_support/callbacks.rb:405:in
    <code>__run_callback' activesupport (3.2.8)
    lib/active_support/callbacks.rb:385:in</code>_run_call_callbacks'
    activesupport (3.2.8) lib/active_support/callbacks.rb:81:in
    <code>run_callbacks' actionpack (3.2.8)
    lib/action_dispatch/middleware/callbacks.rb:27:in</code>call' actionpack
    (3.2.8) lib/action_dispatch/middleware/reloader.rb:65:in <code>call'
    actionpack (3.2.8) lib/action_dispatch/middleware/remote_ip.rb:31:in
    </code>call' actionpack (3.2.8)
    lib/action_dispatch/middleware/debug_exceptions.rb:16:in <code>call'
    actionpack (3.2.8)
    lib/action_dispatch/middleware/show_exceptions.rb:56:in</code>call'
    railties (3.2.8) lib/rails/rack/logger.rb:26:in <code>call_app' railties
    (3.2.8) lib/rails/rack/logger.rb:16:in</code>call' actionpack (3.2.8)
    lib/action_dispatch/middleware/request_id.rb:22:in <code>call' rack (1.4.1)
    lib/rack/methodoverride.rb:21:in</code>call' rack (1.4.1)
    lib/rack/runtime.rb:17:in <code>call' activesupport (3.2.8)
    lib/active_support/cache/strategy/local_cache.rb:72:in</code>call' rack
    (1.4.1) lib/rack/lock.rb:15:in <code>call' actionpack (3.2.8)
    lib/action_dispatch/middleware/static.rb:62:in</code>call' railties (3.2.8)
    lib/rails/engine.rb:479:in <code>call' railties (3.2.8)
    lib/rails/application.rb:223:in</code>call' rack (1.4.1)
    lib/rack/content_length.rb:14:in <code>call' railties (3.2.8)
    lib/rails/rack/log_tailer.rb:17:in</code>call' rack (1.4.1)
    lib/rack/handler/webrick.rb:59:in <code>service'
    /home/jashwant/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:138:in
    </code>service'
    /home/jashwant/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:94:in
    <code>run'
    /home/jashwant/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/server.rb:191:in
    </code>block in start_thread'</p>
  </blockquote>
  
  <p>I am not using database for now. I tried to do <code>rake db:migrate</code> but it returns the same error.</p>
  
  <p>I am on Ubuntu 12.04 (as some bugs on google were related to ubuntu)</p>
  
  <p>I have found similar questions on SO, but they are experiencing at  some advance stage and thus involves some advance solutions.</p>