*This is using Google translate. The text may be unnatural. I’m from Japan.
I have deployed a Rails 7 project to a Web service. but The app has an error.
That is:
ActiveRecord::ConnectionNotEstablished: could not translate host name "dpg-xxxxxxxxxxx-x" to address: Name or service not known
Maybe, The PostgreSQL connection is probably failing.
Applicable source codes:
- render.yaml
databases:
name: Xxxxxxxx_production
databaseName: Xxxxxxxx_production_2bm9
user: Xxxxxxxx_production
services:
type: web
name: Xxxxxxxx
env: ruby
buildCommand: "./bin/render-build.sh"
startCommand: "bundle exec puma -C config/puma.rb"
envVars:
key: DATABASE_URL
fromDatabase:
name: Xxxxxxxx_production
property: connectionString
key: RAILS_MASTER_KEY
sync: false
(Xxxxxxxx is my app and DB name)
- ./config/database.yml
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
password: postgresPassword # I don't use it now
username: postgres
host: localhost
encoding: unicode
url: <%= ENV['DATABASE_URL'] %>
# omission
production:
<<: *default
database: Xxxxxxxx_production_2bm9
username: postgreser
password: <%= ENV["Xxxxxxxx_DATABASE_PASSWORD"] %>
adapter: postgresql
port: 5432
- ./bin/render-build.sh
#!/usr/bin/env bash
# exit on error
set -o errexit
bundle install
bundle exec rake assets:precompile
bundle exec rake assets:clean
bundle exec rake db:migrate
- ./config/puma.rb
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
threads min_threads_count, max_threads_count
worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
port ENV.fetch("PORT") { 3000 }
environment ENV.fetch("RAILS_ENV") { "development" }
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
workers ENV.fetch("WEB_CONCURRENCY") { 4 }
preload_app!
plugin :tmp_restart
I need your help now! If you need other information, I will provide the code!
Nice to meet you and thank you!!
I’m a beginner. Sorry.