PG :: Server error unexpectedly closed the connection

I am new to Ruby on rails. I created two basic demos for learning by examples

and suddenly it stops working for my new example application.

I created a Pages controller and two actions home and contact and did not come up with anything.

Now I cannot open any pages except the default index.html page in localhost:3000 by default. The localhost:3000/pages/home and localhost:3000/pages/contact page returns this error.

PG :: Error

Server

unexpectedly closed the connection. This probably means the server is abnormally interrupted before or during request processing.

and sometimes (usually when I restart postgresql)

PG :: Error

Server

unexpectedly closed the connection. This probably means the server is abnormally interrupted before or during request processing. Failed to send startup package: broken handset

This is my stack trace.

activerecord (3.2.8) Library / 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) Library / active _record / connection_adapters / postgresql_adapter.rb: 1213: in connect' activerecord (3.2.8) lib/active_record/connection_adapters/postgresql_adapter.rb:329:in initialize' activerecord (3.2.8) Library / active _record / connection_adapters / postgresql_ .rb: 28: in new' activerecord (3.2.8) lib/active_record/connection_adapters/postgresql_adapter.rb:28:in activerecord postgresql_connection (3.2.8) Library / active_record / connection_adapters / annotation / 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) Library / active_record / connection_adapters / annotation / 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 looper activerecord (3.2.8) Library / active_record /connection_adapters/abstract/connection_pool.rb: 236: in 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) library / active_record / connection_adapters / abstract / connection_pool.rb: 233: in checkout' 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: in mon_synchronize' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:95:in connection 'activerecord (3.2.8) library / active_record / connection_adapters / abstract / c onnection_pool.rb: 404: in retrieve_connection' activerecord (3.2.8) lib/active_record/connection_adapters/abstract/connection_specification.rb:170:in activerecord retrieve_connection (3.2.8) Library / active_record / connection_adapters / annotation / connection_specification.rb: 144 : in connection' activerecord (3.2.8) lib/active_record/query_cache.rb:67:in salvation in a call activerecord (3.2.8) lib / active_record / query_cache.rb: 61: in call' 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: in block 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 . 8) lib / active_support / callbacks.rb: 81: in run_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: in call' 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: in call' actionpack (3.2.8) lib/action_dispatch/middleware/show_exceptions.rb:56:in call 'raines (3.2.8) lib / rails / rack / logger.rb: 26: in call_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: in call' rack (1.4.1) lib/rack/methodoverride.rb:21:in call 'rack (1.4.1) lib / rack / runtime.rb: 17: in call' activesupport (3.2.8) lib/active_support/cache/strategy/local_cache.rb:72:in rack (1.4.1) lib / rack / lock.rb: 15: in call' activesupport (3.2.8) lib/active_support/cache/strategy/local_cache.rb:72:in : in call' actionpack (3.2.8) lib/action_dispatch/middleware/static.rb:62:in call' railties (3.2.8) lib / rails / engine.rb: 479: in call' railties (3.2.8) lib/rails/application.rb:223:in call' railties (3.2.8) lib/rails/application.rb:223:in call 'rack (1.4.1) lib / rack / content_length.rb: 14: in call' railties (3.2.8) lib/rails/rack/log_tailer.rb:17:in call 'rack (1.4 .1) lib / rack / handler / webrick.rb: 59: in service' /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:in run' /home/jashwant/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/server.rb:191:in block in start_thread '

I do not use a database yet. I tried to make rake db:migrate , but it returns the same error.

I'm on Ubuntu 12.04 (since some google errors were related to ubuntu)

I have found similar questions about SO, but they are worried at some advanced stage and therefore involve some preliminary decisions.

+4
source share
1 answer

Although I do not use the database, but specifying the port in the configuration in database.yml solves the problem . By default, the rails new <app_name> --database=postgresql does not put port there.

Here is my configuration.

 development: adapter: postgresql encoding: unicode database: sample_app_development pool: 5 port: 5433 username: myusername password: mypassword reconnect: true 
+3
source

Source: https://habr.com/ru/post/1438603/


All Articles