Recently I forked and cloned a repo I am contributing to and when I run rails s I get no errors, however when I run rake db:migrate I get this.
rake aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
/Users/taimurknaziri/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `initialize'
/Users/taimurknaziri/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `new'
/Users/taimurknaziri/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `connect'
/Users/taimurknaziri/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:568:in `initialize'
/Users/taimurknaziri/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new'
/Users/taimurknaziri/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'
/Users/taimurknaziri/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:435:in `new_connection'
/Users/taimurknaziri/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:445:in `checkout_new_connection'
/Users/taimurknaziri/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `acquire_connection'
/Users/taimurknaziri/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:351:in `block in checkout'
/Users/taimurknaziri/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:350:in `checkout'
/Users/taimurknaziri/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
/Users/taimurknaziri/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
/Users/taimurknaziri/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:541:in `retrieve_connection'
/Users/taimurknaziri/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.4/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/Users/taimurknaziri/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.4/lib/active_record/connection_handling.rb:87:in `connection'
/Users/taimurknaziri/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.4/lib/active_record/migration.rb:910:in `initialize'
/Users/taimurknaziri/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.4/lib/active_record/migration.rb:807:in `new'
/Users/taimurknaziri/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.4/lib/active_record/migration.rb:807:in `up'
/Users/taimurknaziri/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.4/lib/active_record/migration.rb:785:in `migrate'
/Users/taimurknaziri/.rvm/gems/ruby-2.1.1/gems/activerecord-4.1.4/lib/active_record/railties/databases.rake:34:in `block (2 levels) in <top (required)>'
/Users/taimurknaziri/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `eval'
/Users/taimurknaziri/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
I checked out some other threads with other people who had the same problem however their solutions did not really have any luck for me.
I tried uninstalling and reinstalling PG as well as getting rid of the .PID file however it doesn't look like I seem to have one.
Any clues, pointers or advice? Thanks in advance.
This means either your database.yml file in config/ directory is not set up correctly for your environment, most likely development as it is the default or you do not have postgresql running.
If you do not have postgresql running either install it or start it up. You can check postgresql, more than likely with either:
sudo service postgresql status
or
ps -ef | grep postgres
If you do have postgresql running, then check your database.yml file and edit it appropriately, most likely something like:
development:
adapter: postgresql
encoding: unicode
database: database_name
host: localhost
username: user_name
password: password
Related
While trying to deploy in the "Ruby 3.0 running on 64bit Amazon Linux 2/3.6.2" platform, both using the eb deploy command or manually uploading a zipped version of my project, it seems the Postgresql service is not running in my instance since I get the next in eb-engile.log:
2023/01/17 17:31:04.238133 [ERROR] An error occurred during execution of command [app-deploy] - [rake tasks]. Stop running the command. Error: running rake task db:migrate failed with error command bundle exec rake db:migrate failed with error Command /bin/su webapp -c bundle exec rake db:migrate failed with error exit status 1. Stderr:rake aborted!
ActiveRecord::ConnectionNotEstablished: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/connection_adapters/postgresql_adapter.rb:83:in `rescue in new_client'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/connection_adapters/postgresql_adapter.rb:77:in `new_client'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `postgresql_connection'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `public_send'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `new_connection'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:926:in `checkout_new_connection'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:905:in `try_to_checkout_new_connection'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:866:in `acquire_connection'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:588:in `checkout'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:428:in `connection'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:1128:in `retrieve_connection'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/connection_handling.rb:327:in `retrieve_connection'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/connection_handling.rb:283:in `connection'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/tasks/database_tasks.rb:237:in `migrate'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/railties/databases.rake:92:in `block (3 levels) in <main>'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/railties/databases.rake:90:in `each'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/railties/databases.rake:90:in `block (2 levels) in <main>'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/opt/elasticbeanstalk/.rbenv/versions/3.0.5/bin/bundle:25:in `load'
/opt/elasticbeanstalk/.rbenv/versions/3.0.5/bin/bundle:25:in `<main>'
Caused by:
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/pg-1.2.3/lib/pg.rb:58:in `initialize'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/pg-1.2.3/lib/pg.rb:58:in `new'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/pg-1.2.3/lib/pg.rb:58:in `connect'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/connection_adapters/postgresql_adapter.rb:78:in `new_client'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `postgresql_connection'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `public_send'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `new_connection'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:926:in `checkout_new_connection'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:905:in `try_to_checkout_new_connection'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:866:in `acquire_connection'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:588:in `checkout'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:428:in `connection'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/connection_adapters/abstract/connection_pool.rb:1128:in `retrieve_connection'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/connection_handling.rb:327:in `retrieve_connection'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/connection_handling.rb:283:in `connection'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/tasks/database_tasks.rb:237:in `migrate'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/railties/databases.rake:92:in `block (3 levels) in <main>'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/railties/databases.rake:90:in `each'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/activerecord-6.1.7/lib/active_record/railties/databases.rake:90:in `block (2 levels) in <main>'
/var/app/staging/vendor/bundle/ruby/3.0.0/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/opt/elasticbeanstalk/.rbenv/versions/3.0.5/bin/bundle:25:in `load'
/opt/elasticbeanstalk/.rbenv/versions/3.0.5/bin/bundle:25:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
Although, when trying to run the /bin/su webapp -c bundle exec rake db:migrate command as root (please notice that, I am invoking bundler then as the webapp user), I get different kind of error (trying to install a missing gem?):
Bundler::PermissionError: There was an error while trying to write to
`/var/app/staging/vendor/bundle/ruby/3.0.0/cache/public_suffix-5.0.1.gem`. It is likely that you
need to grant write permissions for that path.
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/shared_helpers.rb:105:in `rescue in
filesystem_access'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/shared_helpers.rb:102:in
`filesystem_access'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/rubygems_integration.rb:479:in `block in
download_gem'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/retry.rb:40:in `run'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/retry.rb:30:in `attempt'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/rubygems_integration.rb:470:in
`download_gem'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/source/rubygems.rb:485:in `download_gem'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/source/rubygems.rb:447:in `fetch_gem'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/source/rubygems.rb:431:in
`fetch_gem_if_possible'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/source/rubygems.rb:158:in `install'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/installer/gem_installer.rb:54:in
`install'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/installer/parallel_installer.rb:155:in
`do_install'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/installer/parallel_installer.rb:140:in
`install_serially'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/installer/parallel_installer.rb:91:in
`call'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/installer/parallel_installer.rb:67:in
`call'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/installer.rb:244:in
`install_in_parallel'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/installer.rb:201:in `install'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/installer.rb:89:in `block in run'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/process_lock.rb:19:in `rescue in lock'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/process_lock.rb:15:in `lock'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/installer.rb:71:in `run'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/installer.rb:23:in `install'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/cli/install.rb:62:in `run'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/cli.rb:260:in `block in install'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/settings.rb:131:in `temporary'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/cli.rb:259:in `install'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/vendor/thor/lib/thor/command.rb:27:in
`run'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in
`invoke_command'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/vendor/thor/lib/thor.rb:392:in
`dispatch'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/cli.rb:34:in `dispatch'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/vendor/thor/lib/thor/base.rb:485:in
`start'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/cli.rb:28:in `start'
/opt/rubies/ruby-3.0.5/lib/ruby/gems/3.0.0/gems/bundler-2.4.1/exe/bundle:45:in `block in <top
(required)>'
/opt/rubies/ruby-3.0.5/lib/ruby/site_ruby/3.0.0/bundler/friendly_errors.rb:117:in
`with_friendly_errors'
/opt/rubies/ruby-3.0.5/lib/ruby/gems/3.0.0/gems/bundler-2.4.1/exe/bundle:33:in `<top
(required)>'
/opt/elasticbeanstalk/.rbenv/versions/3.0.5/bin/bundle:25:in `load'
/opt/elasticbeanstalk/.rbenv/versions/3.0.5/bin/bundle:25:in `<main>'
An error occurred while installing public_suffix (5.0.1), and Bundler cannot
continue.
In Gemfile:
capybara was resolved to 3.38.0, which depends on
addressable was resolved to 2.8.1, which depends on
public_suffix
It also seems the postgresql service is not installed (checked installed services starting with the "post" string):
[root#ip************ staging]# systemctl list-unit-files | grep post
postfix.service enabled
So, the question is, how do I make the eb deploy command run without failing? given that:
I see one error using eb deploy that highlights a failing rake db:migrate command but, when trying to running it manually after connecting through SSH it throws a different error; the one that mentions public_suffix. This seems unexpected.
The postgresql service should be installed in AWS's managed platform, as with previous versions
Adding a database to your Elastic Beanstalk environment
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.managing.db.html
It looks like your app is trying to connect to a local database server:
Caused by:
PG::ConnectionBad: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
What are the contents of your config/database.yml? Is it reading environment variables that elasticbeanstalk knows to pass in? Does your RDS instance have the right access rules set up to allow connections from EB?
I've been trying to install the Consul software for a few hours. For this I use the installation instructions https://docs.consulproject.org/docs/english-documentation/introduction/local_installation
Unfortunately, I have virtually no idea about Ruby, Postgres, etc.
Unfortunately, I get an error message when I run the following commands.
rake db: create
rake db: setup
rake db: dev_seed
rake db: test: prepare
Here is the entire issue:
rake db:create
/var/lib/gems/2.7.0/gems/dry-types-0.13.3/lib/dry/types/definition.rb:31: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/var/lib/gems/2.7.0/gems/dry-types-0.13.3/lib/dry/types/options.rb:8: warning: The called method `initialize' is defined here
/var/lib/gems/2.7.0/gems/dry-types-0.13.3/lib/dry/types/decorator.rb:13: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/var/lib/gems/2.7.0/gems/dry-types-0.13.3/lib/dry/types/options.rb:8: warning: The called method `initialize' is defined here
/var/lib/gems/2.7.0/gems/dry-types-0.13.3/lib/dry/types/sum.rb:43: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/var/lib/gems/2.7.0/gems/dry-types-0.13.3/lib/dry/types/options.rb:8: warning: The called method `initialize' is defined here
warning: parser/current is loading parser/ruby27, which recognizes
warning: 2.7.2-compliant syntax, but you are running 2.7.0.
warning: please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/type.rb:27: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/type/adapter_specific_registry.rb:9: warning: The called method `add_modifier' is defined here
/var/lib/gems/2.7.0/gems/acts-as-taggable-on-6.5.0/lib/acts_as_taggable_on/tagging.rb:9: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/associations.rb:1653: warning: The called method `belongs_to' is defined here
/var/lib/gems/2.7.0/gems/actionpack-5.2.4.4/lib/action_dispatch/middleware/stack.rb:37: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
/var/lib/gems/2.7.0/gems/actionpack-5.2.4.4/lib/action_dispatch/middleware/static.rb:111: warning: The called method `initialize' is defined here
could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
Couldn't create 'consul_development' database. Please check your configuration.
rake aborted!
PG::ConnectionBad: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
/var/lib/gems/2.7.0/gems/pg-1.0.0/lib/pg.rb:56:in `initialize'
/var/lib/gems/2.7.0/gems/pg-1.0.0/lib/pg.rb:56:in `new'
/var/lib/gems/2.7.0/gems/pg-1.0.0/lib/pg.rb:56:in `connect'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/postgresql_adapter.rb:692:in `connect'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/postgresql_adapter.rb:223:in `initialize'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/postgresql_adapter.rb:48:in `new'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/postgresql_adapter.rb:48:in `postgresql_connection'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:830:in `new_connection'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:874:in `checkout_new_connection'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:853:in `try_to_checkout_new_connection'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:814:in `acquire_connection'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:538:in `checkout'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:382:in `connection'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:1033:in `retrieve_connection'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/connection_handling.rb:118:in `retrieve_connection'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/connection_handling.rb:90:in `connection'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/postgresql_database_tasks.rb:12:in `connection'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/postgresql_database_tasks.rb:21:in `create'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:119:in `create'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:139:in `block in create_current'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:316:in `block in each_current_configuration'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:313:in `each'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:313:in `each_current_configuration'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/tasks/database_tasks.rb:138:in `create_current'
/var/lib/gems/2.7.0/gems/activerecord-5.2.4.4/lib/active_record/railties/databases.rake:29:in `block (2 levels) in <top (required)>'
/var/lib/gems/2.7.0/gems/airbrake-5.8.1/lib/airbrake/rake/task_ext.rb:19:in `execute'
/usr/share/rubygems-integration/all/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/var/lib/gems/2.7.0/gems/bundler-1.17.1/lib/bundler/cli/exec.rb:74:in `load'
/var/lib/gems/2.7.0/gems/bundler-1.17.1/lib/bundler/cli/exec.rb:74:in `kernel_load'
/var/lib/gems/2.7.0/gems/bundler-1.17.1/lib/bundler/cli/exec.rb:28:in `run'
/var/lib/gems/2.7.0/gems/bundler-1.17.1/lib/bundler/cli.rb:463:in `exec'
/var/lib/gems/2.7.0/gems/bundler-1.17.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/var/lib/gems/2.7.0/gems/bundler-1.17.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/var/lib/gems/2.7.0/gems/bundler-1.17.1/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/var/lib/gems/2.7.0/gems/bundler-1.17.1/lib/bundler/cli.rb:27:in `dispatch'
/var/lib/gems/2.7.0/gems/bundler-1.17.1/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/var/lib/gems/2.7.0/gems/bundler-1.17.1/lib/bundler/cli.rb:18:in `start'
/var/lib/gems/2.7.0/gems/bundler-1.17.1/exe/bundle:30:in `block in <top (required)>'
/var/lib/gems/2.7.0/gems/bundler-1.17.1/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
/var/lib/gems/2.7.0/gems/bundler-1.17.1/exe/bundle:22:in `<top (required)>'
/usr/local/bin/bundle:23:in `load'
/usr/local/bin/bundle:23:in `<main>'
Tasks: TOP => db:create
(See full trace by running task with --trace)
Does anyone have any idea how to solve this? Thanks in advance!
This means that Postgresql isn't running so it cannot make the database.
Have you installed Postgres? If so, you can likely start the service by using:
sudo service postgresql restart
If Postgres isn't installed, you first need to install it. How to do so differs depending on your system:
https://www.postgresqltutorial.com/install-postgresql/
When I run rake:db migrate from my rails app, I get this output:
rake aborted!
PG::ConnectionBad: could not connect to server: Connection refused
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
/home/ubuntu/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `initialize'
/home/ubuntu/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `new'
/home/ubuntu/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `connect'
/home/ubuntu/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:568:in `initialize'
/home/ubuntu/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new'
/home/ubuntu/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.4/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'
/home/ubuntu/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:435:in `new_connection'
/home/ubuntu/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:445:in `checkout_new_connection'
/home/ubuntu/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:416:in `acquire_connection'
/home/ubuntu/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:351:in `block in checkout'
/home/ubuntu/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:350:in `checkout'
/home/ubuntu/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `block in connection'
/home/ubuntu/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
/home/ubuntu/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.4/lib/active_record/connection_adapters/abstract/connection_pool.rb:541:in `retrieve_connection'
/home/ubuntu/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.4/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
/home/ubuntu/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.4/lib/active_record/connection_handling.rb:87:in `connection'
/home/ubuntu/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.4/lib/active_record/migration.rb:910:in `initialize'
/home/ubuntu/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.4/lib/active_record/migration.rb:807:in `new'
/home/ubuntu/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.4/lib/active_record/migration.rb:807:in `up'
/home/ubuntu/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.4/lib/active_record/migration.rb:785:in `migrate'
/home/ubuntu/.rvm/gems/ruby-2.1.2/gems/activerecord-4.1.4/lib/active_record/railties/databases.rake:34:in `block (2 levels) in <top (required)>'
/home/ubuntu/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
/home/ubuntu/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'
In my gemfile I have
gem 'pg'
and in my database.yml I have
default: &default
adapter: postgresql
encoding: unicode
pool: 5
development:
<<: *default
database: fake_lunch_hub_development
test:
<<: *default
database: fake_lunch_hub_test
production:
<<: *default
database: fake_lunch_hub_production
username: fake_lunch_hub
password: <%= ENV['FAKE_LUNCH_HUB_DATABASE_PASSWORD'] %>
This setup used to connect to the database perfectly, but I did a lot of refactoring and renaming (the project is no longer called fake_lunch_hub) and I moved the project off of my local machine (mac) and onto an amazon EC2 instance (ubuntu).
There are many other questions on Stackoverflow that offer solutions using psql, but when I run the command
psql
I get this:
The program 'psql' can be found in the following packages:
* postgresql-client-common
* postgres-xc-client
Try: sudo apt-get install <selected package>
I'd rather not download a new postgres package because I already have it successfully downloaded from the gem.
How can I get that server started and accepting connections?
EDIT:
FULL SOLUTION:
sudo apt-get install postgres
sudo su
su postgres
createuser ubuntu
createuser fake_lunch_hub
createdb fake_lunch_hub
exit
exit
rails server
resolves the issues
The gem is just a way for Ruby/Rails to talk to a Postgres server. The gem itself does not contain its own server.
You'll still need to install one:
sudo apt-get install postgresql
I'm just sitting here trying to deploy my app to heroku for the last 4 hours.
I just want to push my changes, but the following appears each and every time I push my changes.
rake aborted!
The driver encountered an unknown error: org.postgresql.util.PSQLException: Connection refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
I'm running a rails 4.0.2 application with jruby 1.7.4 and ruby 1.9.3.
I've already used this extension.
https://devcenter.heroku.com/articles/labs-user-env-compile
But it won't help either.
Here's a more detailed stack trace
/tmp/build_f358186b-fb40-492f-93f9-f05fa7b3f751/vendor/bundle/jruby/1.9/gems/activerecord-jdbc-adapter-1.3.5/lib/arjdbc/jdbc/connection.rb:23:in `initialize'
/tmp/build_f358186b-fb40-492f-93f9-f05fa7b3f751/vendor/bundle/jruby/1.9/gems/activerecord-jdbc-adapter-1.3.5/lib/arjdbc/jdbc/adapter.rb:68:in `initialize'
/tmp/build_f358186b-fb40-492f-93f9-f05fa7b3f751/vendor/bundle/jruby/1.9/gems/activerecord-jdbc-adapter-1.3.5/lib/arjdbc/postgresql/adapter.rb:1275:in `initialize'
/tmp/build_f358186b-fb40-492f-93f9-f05fa7b3f751/vendor/bundle/jruby/1.9/gems/activerecord-jdbc-adapter-1.3.5/lib/arjdbc/jdbc/connection_methods.rb:12:in `jdbc_connection'
/tmp/build_f358186b-fb40-492f-93f9-f05fa7b3f751/vendor/bundle/jruby/1.9/gems/activerecord-jdbc-adapter-1.3.5/lib/arjdbc/postgresql/connection_methods.rb:45:in `postgresql_connection'
org/jruby/RubyBasicObject.java:1709:in `__send__'
org/jruby/RubyKernel.java:2213:in `send'
/tmp/build_f358186b-fb40-492f-93f9-f05fa7b3f751/vendor/bundle/jruby/1.9/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:440:in `new_connection'
/tmp/build_f358186b-fb40-492f-93f9-f05fa7b3f751/vendor/bundle/jruby/1.9/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:450:in `checkout_new_connection'
/tmp/build_f358186b-fb40-492f-93f9-f05fa7b3f751/vendor/bundle/jruby/1.9/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:421:in `acquire_connection'
/tmp/build_f358186b-fb40-492f-93f9-f05fa7b3f751/vendor/bundle/jruby/1.9/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:356:in `checkout'
/tmp/build_f358186b-fb40-492f-93f9-f05fa7b3f751/vendor/bundle/jruby/1.9/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:355:in `checkout'
/tmp/build_f358186b-fb40-492f-93f9-f05fa7b3f751/vendor/bundle/jruby/1.9/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:265:in `connection'
/tmp/build_f358186b-fb40-492f-93f9-f05fa7b3f751/vendor/bundle/jruby/1.9/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:264:in `connection'
/tmp/build_f358186b-fb40-492f-93f9-f05fa7b3f751/vendor/bundle/jruby/1.9/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:546:in `retrieve_connection'
/tmp/build_f358186b-fb40-492f-93f9-f05fa7b3f751/vendor/bundle/jruby/1.9/gems/activerecord-4.0.2/lib/active_record/connection_handling.rb:79:in `retrieve_connection'
/tmp/build_f358186b-fb40-492f-93f9-f05fa7b3f751/vendor/bundle/jruby/1.9/gems/activerecord-4.0.2/lib/active_record/connection_handling.rb:53:in `connection'
/tmp/build_f358186b-fb40-492f-93f9-f05fa7b3f751/vendor/bundle/jruby/1.9/gems/activerecord-4.0.2/lib/active_record/model_schema.rb:203:in `table_exists?'
/tmp/build_f358186b-fb40-492f-93f9-f05fa7b3f751/vendor/bundle/jruby/1.9/gems/activerecord-4.0.2/lib/active_record/attribute_methods.rb:123:in `attribute_method?'
/tmp/build_f358186b-fb40-492f-93f9-f05fa7b3f751/vendor/bundle/jruby/1.9/gems/activemodel-4.0.2/lib/active_model/validations/acceptance.rb:16:in `setup'
org/jruby/RubyArray.java:2651:in `reject!'
org/jruby/RubyArray.java:2614:in `reject'
/tmp/build_f358186b-fb40-492f-93f9-f05fa7b3f751/vendor/bundle/jruby/1.9/gems/activemodel-4.0.2/lib/active_model/validations/acceptance.rb:16:in `setup'
/tmp/build_f358186b-fb40-492f-93f9-f05fa7b3f751/vendor/bundle/jruby/1.9/gems/activemodel-4.0.2/lib/active_model/validations/with.rb:88:in `validates_with'
org/jruby/RubyArray.java:1617:in `each'
/tmp/build_f358186b-fb40-492f-93f9-f05fa7b3f751/vendor/bundle/jruby/1.9/gems/activemodel-4.0.2/lib/active_model/validations/with.rb:86:in `validates_with'
/tmp/build_f358186b-fb40-492f-93f9-f05fa7b3f751/vendor/bundle/jruby/1.9/gems/activemodel-4.0.2/lib/active_model/validations/acceptance.rb:51:in `validates_acceptance_of'
/tmp/build_f358186b-fb40-492f-93f9-f05fa7b3f751/app/models/user.rb:20:in `User'
/tmp/build_f358186b-fb40-492f-93f9-f05fa7b3f751/app/models/user.rb:1:in `(root)'
So this one was really really odd.
After nearly one whole day debugging I was able to solve the issue.
It has nothing to do with jRuby, nor with the active-record Adapter (you get a very similar error if you push this to heroku with a ruby-Runtime rather than a jruby-Runtime).
The issues was caused by this line in one of my models
validates_presence_of :terms_of_service
After commenting it out and pushing it to heroku again everything is fine.
Odd...
Can you try this?
Set username: systemuser, host: localhost in your YAML file
If above solution doesn't work, please refer to this link:
http://www.revsys.com/writings/postgresql/errors.html
Hope this solves your issue!
Super stumped by why Postgres isn't working on a new app I just started. I've got it working for one app already. I'm using postgres.app, and it's running.
I started a new app with
rails new depot -d postgresql
and then I went into the database.yml file and changed username to my $USER (which is what it is for the other app, which is working). So now my database.yml file has this development section:
development:
adapter: postgresql
encoding: unicode
database: depot_development
pool: 5
username: <username>
password:
But when I run "rake db:create" or "rake db:create:all" I still got this error (in full, cause I don't know what's relevant):
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "database"=>"depot_development", "pool"=>5, "username"=>"<username>", "password"=>nil}
could not connect to server: Permission denied
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
/Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1213:in `initialize'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1213:in `new'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1213:in `connect'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:329:in `initialize'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `new'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `postgresql_connection'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:309:in `new_connection'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:319:in `checkout_new_connection'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:241:in `block (2 levels) in checkout'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:236:in `loop'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:236:in `block in checkout'
/Users/<username>/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:233:in `checkout'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:96:in `block in connection'
/Users/<username>/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:95:in `connection'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:404:in `retrieve_connection'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:170:in `retrieve_connection'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract/connection_specification.rb:144:in `connection'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/railties/databases.rake:107:in `rescue in create_database'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/railties/databases.rake:51:in `create_database'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/railties/databases.rake:40:in `block (3 levels) in <top (required)>'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/railties/databases.rake:40:in `each'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.8/lib/active_record/railties/databases.rake:40:in `block (2 levels) in <top (required)>'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/<username>/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194#global/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194#global/bin/rake:19:in `load'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194#global/bin/rake:19:in `<main>'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `eval'
/Users/<username>/.rvm/gems/ruby-1.9.3-p194/bin/ruby_noexec_wrapper:14:in `<main>'
Couldn't create database for {"adapter"=>"postgresql", "encoding"=>"unicode", "database"=>"depot_test", "pool"=>5, "username"=>"<username>", "password"=>nil}
I have tried
createdb depot_development
I have tried going into the psql environment and listing users (which included my username among them). In the same psql environment, I tried
CREATE DATABASE depot;
I've made sure that the pg gem is installed with bundle install, I've run "pg_ctl start", to which I got this response:
pg_ctl: no database directory specified and environment variable PGDATA unset
I ran "ps aux | grep postgres" to make sure postgres was running, to which I got this in return (which looks like it's doing OK, right?):
<username> 10390 0.4 0.0 2425480 180 s000 R+ 6:15PM 0:00.00 grep postgres
<username> 2907 0.0 0.0 2441604 464 ?? Ss 6:17PM 0:02.31 postgres: stats collector process
<username> 2906 0.0 0.0 2445520 1664 ?? Ss 6:17PM 0:02.33 postgres: autovacuum launcher process
<username> 2905 0.0 0.0 2445388 600 ?? Ss 6:17PM 0:09.25 postgres: wal writer process
<username> 2904 0.0 0.0 2445388 1252 ?? Ss 6:17PM 0:12.08 postgres: writer process
<username> 2902 0.0 0.0 2445388 3688 ?? S 6:17PM 0:00.54 /Applications/Postgres.app/Contents/MacOS/bin/postgres -D /Users/<username>/Library/Application Support/Postgres/var -p5432
The short of it, is I've been troubleshooting for a WHILE and have NO idea what's wrong. Any ideas? I'd really appreciate it, cause I'm pretty new to Rails, and this is a pretty disheartening roadblock.
Thanks!
EDIT -- Per request, posting the successful database.yml . It seems the difference is the inclusion of a password:
development:
adapter: postgresql
encoding: unicode
database: *******_development
pool: 5
username: *******
password: *******
EDIT2 -- When I add a password to the .yml file, then run rake db:create again, I get the same error. And I'm running Mac OSX Lion, and I did initdb and stuff when I first installed PostgreSQL.
In order to create a database , before starting the command pg_ctl start
you have to initialize the database cluster then only pg_ctl start shall be success full*
this can be done in many ways
if you are running on Linux / centos with postgres 9.1
service postgresql-9.1 initdb
service postgresql-9.1 start
or you can do like this
$ mkdir -p /var/pgsql/data; chown -R postgres /var/pgsql
$ su - postgres
$ initdb -D /var/pgsql/data
# Starting, testing:
$ postgres -D /var/pgsql/data > /var/pgsql/logfile 2>&1 &
$ createdb test
$ psql test
Initializing postgres initb differes from os to os and postgres versions , if the above command did not work please have a look at
Adding
host: localhost
to development works for me.