Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Puma Postgres Server to Work in Development to Cooperate with Heroku, or does going back to Sqlite make sense?

I got using puma instead of rails s to work fine for awhile, but then while developing and making code changes and refreshing at some point the refresh wasn't working, delaying for a long time. I assumed it had crashed or something, so I killed the puma server, but then it said 'gracefully shutting down' for several minutes so I killed the terminal window. Then, in a new window when I tried to use puma it said the host was already taken, so the process was still running. Unable to find where it was, I restarted my computer. Upon restart, I now get the error An unhandled lowlevel error occured. The application logs may have details. or PG::ConnectionBad fe_sendauth: no password supplied, depending on whether I run puma or RAILS_ENV=development puma.

Neither of these responses seem to make sense, and this error I see others having on rake db:migrate. So I tried migrating the database and got the same error PG::ConnectionBad: fe_sendauth: no password supplied

And in the logs when trying to run the server: Rack app error: #<RuntimeError: Missingsecret_key_basefor 'production' environment, set this value inconfig/secrets.yml>

Now this makes the least sense to me, as why is puma running production environment by default and requiring a special command to run in development?

production:
  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>

Is dependent on Heroku to pass the secret_key_base is my assumption, so it doesn't work for development. But then even RAILS_ENV=development puma throws

PG::ConnectionBad
fe_sendauth: no password supplied

And a trace that doesn't appear to help me:

activerecord (4.1.7) lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `initialize'
activerecord (4.1.7) lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `new'
activerecord (4.1.7) lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `connect'
activerecord (4.1.7) lib/active_record/connection_adapters/postgresql_adapter.rb:568:in `initialize'
activerecord (4.1.7) lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new'
activerecord (4.1.7) lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'
activerecord (4.1.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:435:in `new_connection'
activerecord (4.1.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:445:in `checkout_new_connection'
activerecord (4.1.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `acquire_connection'
activerecord (4.1.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:351:in `block in checkout'
/Users/lasernite/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
activerecord (4.1.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:350:in `checkout'
activerecord (4.1.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
/Users/lasernite/.rvm/rubies/ruby-2.1.4/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
activerecord (4.1.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
activerecord (4.1.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:541:in `retrieve_connection'
activerecord (4.1.7) lib/active_record/connection_handling.rb:113:in `retrieve_connection'
activerecord (4.1.7) lib/active_record/connection_handling.rb:87:in `connection'
activerecord (4.1.7) lib/active_record/migration.rb:388:in `check_pending!'
activerecord (4.1.7) lib/active_record/migration.rb:377:in `call'
actionpack (4.1.7) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.7) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.7) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.1.7) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.1.7) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.1.7) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.1.7) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.7) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.7) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.7) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.7) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.7) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.7) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.1.7) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.1.7) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.1.7) lib/action_dispatch/middleware/static.rb:84:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
rack-timeout (0.2.0) lib/rack/timeout.rb:108:in `call'
railties (4.1.7) lib/rails/engine.rb:514:in `call'
railties (4.1.7) lib/rails/application.rb:144:in `call'
puma (2.11.0) lib/puma/configuration.rb:82:in `call'
puma (2.11.0) lib/puma/server.rb:507:in `handle_request'
puma (2.11.0) lib/puma/server.rb:375:in `process_client'
puma (2.11.0) lib/puma/server.rb:262:in `block in run'
puma (2.11.0) lib/puma/thread_pool.rb:104:in `call'
puma (2.11.0) lib/puma/thread_pool.rb:104:in `block in spawn_thread'

I'm stuck on where to try and resolve this error.

Please give any insight you can. Thanks!

like image 916
Laser Avatar asked Dec 20 '22 07:12

Laser


1 Answers

Is your "config/secrets.yml" file listed in .gitignore? Heroku needs that file. Remove or comment it out from .gitignore. I had the same problem and that was my issue.

Also, see this post for the same answer: How to solve error "Missing `secret_key_base` for 'production' environment" (Rails 4.1)

Good luck!

like image 127
Stigly Avatar answered May 16 '23 07:05

Stigly