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の内容(特に本番環境)を合わせてあげてください。
怖すぎ、、、