Can't connect droplet with cluster database | Rails|

Hi guys im new in Digital Ocean and im trying to deploy a personal project. My issue happens when i try to migrate into a production database in a droplet rails app

This is my database.YML

  • default: &default

  • adapter: postgresql

  • encoding: unicode

  • pool: <%= ENV.fetch(“RAILS_MAX_THREADS”) { 5 } %>

  • production:

  • <<: *default

  • secret_key_base: <%= ENV[“SECRET_KEY”] %>

  • username: <%= ENV[“DATABASE_USER”] %>

  • password: <%= ENV[“DATABASE_PASSWORD”] %>

  • database: <%= ENV[“DATABASE”] %>

  • host: <%= ENV[“DATABASE_HOST”] %>

these are the steps im following

  1. Cd Into rails app on VM
  2. rails s -d -b RAILS_ENV=production

At this point the production server is “online”

then i want to get migrations by running this:

  1. rake db:migrate RAILS_ENV=production

and this is the issue:

Caused by:PG::ConnectionBad: FATAL: database “root” does not exist

Rails -v

Ruby -v 2.7.1

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
July 1, 2022
Accepted Answer

Hi there,

The error that you are getting indicates that you’ve defined root as the database that you want to use, but that database does not seem to exist.

What I could suggest is:

  • Connect to your Managed database with any SQL client like Table Plus or DBever.
  • Create a new database for your project.
  • Then use that new database in your env variables.

For more information on how to do that you can follow the steps here:



Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel