0

I just deleted and recloned my Rails + PostgreSQL app, but now it seems to look for the database postgres despite it not being specified anywhere.

Using Rails 4.2 and PostgreSQL 9.4.

% bundle exec rake db:create RAILS_ENV=production
ERROR:  No such database: postgres
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:436:in `new_connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:446:in `checkout_new_connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/usr/local/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/usr/local/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:565:in `retrieve_connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:87:in `connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/postgresql_database_tasks.rb:8:in `connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/postgresql_database_tasks.rb:30:in `drop'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:114:in `drop'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:128:in `block in drop_current'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:275:in `block in each_current_configuration'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:274:in `each'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:274:in `each_current_configuration'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:127:in `drop_current'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/railties/databases.rake:28:in `block (2 levels) in <top (required)>'
/usr/local/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/usr/local/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/usr/local/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/usr/local/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/usr/local/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/usr/local/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/usr/local/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/usr/local/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/usr/local/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/usr/local/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/usr/local/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/usr/local/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/usr/local/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/usr/local/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/home/example/bin/rake:8:in `<main>'
Couldn't drop example
example@konge:~% bundle exec rake db:create RAILS_ENV=production
ERROR:  No such database: postgres
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `initialize'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `new'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:651:in `connect'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:242:in `initialize'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `new'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/postgresql_adapter.rb:44:in `postgresql_connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:436:in `new_connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:446:in `checkout_new_connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:422:in `acquire_connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:349:in `block in checkout'
/usr/local/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:348:in `checkout'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:263:in `block in connection'
/usr/local/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:262:in `connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:565:in `retrieve_connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/connection_handling.rb:87:in `connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/postgresql_database_tasks.rb:8:in `connection'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/postgresql_database_tasks.rb:17:in `create'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:93:in `create'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:107:in `block in create_current'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:275:in `block in each_current_configuration'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:274:in `each'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:274:in `each_current_configuration'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/tasks/database_tasks.rb:106:in `create_current'
/home/example/vendor/bundle/ruby/2.2.0/gems/activerecord-4.2.0/lib/active_record/railties/databases.rake:17:in `block (2 levels) in <top (required)>'
/usr/local/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/usr/local/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/usr/local/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/usr/local/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/usr/local/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/local/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/usr/local/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/usr/local/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/usr/local/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/usr/local/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/local/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/usr/local/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/usr/local/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/usr/local/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/usr/local/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/usr/local/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/usr/local/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/home/example/bin/rake:8:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "username"=>"example", "password"=>"example1234", "database"=>"example", "port"=>6543, "prepared_statements"=>false}

database.yml:

production:
  adapter: postgresql
  username: example
  password: example1234
  database: example
  port: 6543
  prepared_statements: false

development:
  adapter: postgresql
  password: example1234
  database: example

test:
  adapter: postgresql
4
  • 3
    From the error log, it's looking for the right database name: Couldn't create database for {"adapter"=>"postgresql", "username"=>"example", "password"=>"example1234", "database"=>"example", "port"=>6543, "prepared_statements"=>false} -- I think you should start by looking at the port being used, 6543. Your "db:create" cannot connect to a running instance of PostgreSQL on port 6543.. Commented Jun 17, 2015 at 18:40
  • That's my PostgreSQL connection pool actually: wiki.postgresql.org/wiki/PgBouncer -- come to think of it, I've never attempted recreating my database after it was installed. Commented Jun 17, 2015 at 18:42
  • Thank you, that was the culprit. I must enable PgBouncer in database.yml after my database has been created. Commented Jun 17, 2015 at 18:43
  • I hope it's as simple as that. Good luck! Commented Jun 17, 2015 at 18:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.