I\'m trying to use rails 4.2.6 to develop an app. I\'m trying to use postgres for database. Server starts fine but when I try loading a page it throws this \"No connection p
This issue arises when the server cannot find the corresponding database it depends on to pull data from.
I had same issue from my end, I updated my version of Sqlite3, and it was higher than the version that the current Puma Server version supports.
I simply had to uninstall the Sqlite3 version, and then install the version supported by the current version of Puma Server.
gem uninstall sqlite3
This will uninstall the updated version of Sqlite3, and then you run the code below stating the version supported by your current server.
gem install sqlite3
Or you can as well open your Gemfile, and then include the version for the database that you are using
gem 'sqlite3', '~> 1.3.6'
N/B: The sqlite3 version is the most current version as at the time of writing this answer
And then run
bundle update
to install the version of the database that you specified.
That's all.
I hope this helps.
Rails 5
New app
Using Postgresql for both test and development
Specs run, so Rails can connect to Postgresql
But when I started the web app, I got "No connection pool with id primary found."
Ran 'bin/rails db:migrate:reset' and restarted the app. It worked. No idea why.
database.yml:
development:
adapter: postgresql
encoding: unicode
database: rails5_development
pool: 5
username: foo
password: bar
host: localhost
port: 5432
test:
adapter: postgresql
encoding: unicode
database: rails5_test
pool: 5
username: foo
password: bar
host: localhost
port: 5432
when you are running rails db:migrate
in data base rows will be created according to your migration files. you can see schema for further info.
If you are experiencing this error from a rake task, chances are you are not running the :environment
task before your task.
Changing:
task :task_name do
end
to:
task task_name: :environment do
end
Should fix the issue.
Check the database.yml
if all settings are ok. If its the first time and you didn't create the database yet use this command to create the database
rake db:create
If the database already exists try reset the db migrations,
rake db:migrate:reset
Hope it'll solve the problem. Go to rails console and try something to check if its working or not.
I had to simply restart the server for the warning to go away.