DB fails to boot locally after Rails deployment.

Asked 1 years ago, Updated 1 years ago, 400 views

What you can't do
After successfully deploying my own application on Render.com, I tried to proceed with the development locally, but now I can't access DB.

Error Contents
I was going to test with Rspec, but I got an error, so I tried rails db:reset.Then, similarly, the following error occurred:

rails aborted!
ActiveRecord:: ConnectionNotEstablished: could not translate host name "xxxxxxxxxx" to address: Name or service not known

What do you want to do
I would like to resolve this error and continue to develop it locally.

Concerns
I searched the error statement and found an article that seemed to be a solution, but I'm worried that it might affect the person who deployed it.If anyone knows, please advise.

ruby-on-rails ruby postgresql

2022-12-11 23:07

1 Answers

Have you changed database.yml?

I think render.com puts connection information in the DATABASE_URL environment variable, so if that's the case, I think it's common to use different settings in the same file as the local one.

default:&default
  adapter —postgresql
  encoding:unicode
  pool:<%=ENV.fetch("RAILS_MAX_THREADS"){5}%>
  host:<%=ENV.fetch("DB_HOST"){"localhost"}%>
  port:<%=ENV.fetch("DB_PORT"){532}%>
  username:<%=ENV.fetch("DB_USERNAME"){"postgres"}%>
  password:<%=ENV.fetch("DB_PASSWORD"){"password"}%>

development:
  <<:* default
  database:myapp_development

test:
  <<:* default
  database —myapp_test

production:
  adapter —postgresql
  encoding:unicode
  pool:<%=ENV.fetch("RAILS_MAX_THREADS"){5}%>
  url:<%=ENV.fetch("DATABASE_URL"){"}%>

I don't know what's going on, so I can't help it any more


2022-12-12 00:28

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.