2
2

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 3 years have passed since last update.

【Rails】前までEC2の本番環境が動いていたのにcapistranoでの自動デプロイを実装した後に改めて本番環境で動かすと111: Connection refusedになる際の対処法

Last updated at Posted at 2020-05-12

capistranoを実装した後、改めてec2で本番環境を起動すると次のエラーが表示される。

15.179.212, request: "GET / HTTP/1.1", upstream: "http://unix:/var/www/rails/Portfolio/tmp/sockets/unicorn.sock:/", host: "13.115.179.212:80"
2020/05/10 13:10:51 [error] 3847#0: *17 connect() to unix:/var/www/rails/Portfolio/tmp/sockets/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 121.3.47.42, server: 13.115.179.212, request: "GET / HTTP/1.1", upstream: "http://unix:/var/www/rails/Portfolio/tmp/sockets/unicorn.sock:/", host: "13.115.179.212"
2020/05/10 13:10:52 [error] 3847#0: *17 connect() to unix:/var/www/rails/Portfolio/tmp/sockets/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 121.3.47.42, server: 13.115.179.212, request: "GET / HTTP/1.1", upstream: "http://unix:/var/www/rails/Portfolio/tmp/sockets/unicorn.sock:/", host: "13.115.179.212"
2020/05/10 13:10:53 [error] 3847#0: *17 connect() to unix:/var/www/rails/Portfolio/tmp/sockets/unicorn.sock failed (111: Connection refused) while connecting to upstream, client: 121.3.47.42, server: 13.115.179.212, request: "GET / HTTP/1.1", upstream: "http://unix:/var/www/rails/Portfolio/tmp/sockets/unicorn.sock:/", host: "13.115.179.212"

##原因

capistranoを入れると、ec2内にあるdatabase.ymlファイルの参照先が変わります。

capistranoを実装する前はEc2内のアプリ名/config.database.ymlでしたが、capistranoを入れた後はEC2内がアプリ名/shared/config/database.ymlになります。

したがって上記のエラーが出る際はローカルのconfig/database.ymlとec2内のshared/config/database.ymlの内容(特に本番環境)を合わせてあげてください。

怖すぎ、、、

2
2
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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?