1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Rails】development以外の環境のコンソールに入ったときのConnection refusedエラー

Posted at

環境

Rails 6.0.1
Ruby 2.6.3
PostgreSQL 11.16

development以外の環境のコンソールに入りたいとき

rails console -e production

コンソールに下記のエラーで入れなかったとき

could not connect to server: Connection refused

database.yml内のhost名をdocker-compose.ymlで定義されているDB用コンテナ名と一致させる。

docker-compose.yml
environment:
  DB_HOST: postgres
  DB_NAME: hoge_development
  DB_NAME_TEST: hoge_test
  DB_USERNAME: postgres
  DB_PASSWORD: password
  REDIS_HOST: redis
config/database.yml
production:
  <<: *default
  host: postgres
  username: postgres
  database: hoge_development
  password: password

参考

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?