設定を変えていないのにAWSの本番環境で急に404 Not Foundが表示されました。
capistranoでデプロイをしたところ、下記のエラーが表示されました。
Tasks: TOP => deploy:migrate (See full trace by running task with --trace) The deploy has failed with an error: Exception while executing as shogo@13.115.179.212: Exception while executing as shogo@13.115.179.212: rake exit status: 1 rake stdout: Nothing written rake stderr: /var/www/rails/Portfolio/shared/bundle/ruby/2.6.0/gems/bootstrap-4.4.1/lib/bootstrap/version.rb:four: warning: already initialized constant Bootstrap::VERSION /var/www/rails/Portfolio/shared/bundle/ruby/2.6.0/gems/bootstrap-sass-3.4.1/lib/bootstrap-sass/version.rb:two: warning: previous definition of VERSION was here /var/www/rails/Portfolio/shared/bundle/ruby/2.6.0/gems/bootstrap-4.4.1/lib/bootstrap/version.rb:five: warning: already initialized constant Bootstrap::BOOTSTRAP_SHA /var/www/rails/Portfolio/shared/bundle/ruby/2.6.0/gems/bootstrap-sass-3.4.1/lib/bootstrap-sass/version.rb:three: warning: previous definition of BOOTSTRAP_SHA was here rake aborted! PG::ConnectionBad: could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 13.115.179.212?
したがって一度ec2を再起動してみたところ、本番環境で画像のような404notfoundエラーが表示されました。
##推測
・nginxは起動している。
・unicornのエラー?
→unicorn_rails -c /var/www/rails/Portfolio/config/unicorn.conf.rb -D -E productionコマンドの後、grep unicorn | grep -v grepをするとIPアドレスも表示されない状態が続く。
capistranoではなく、unicornのエラーだと思いec2内のファイルをみてみたのですがエラーが出る前と全く変わっていないため原因がわかりません。
行ったこと
・改めてアプリ名.conf.rb、unicorn.conf.rbのファイルを作り直し、ec2を再起動しましたが同じエラーが表示されました。
以下、ログになります。
cat log/nginx.error.logの結果
15.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"
cat log/unicorn.log
I, [2020-05-13T03:05:37.408119 #3494] INFO -- : reaped #<Process::Status: pid 3498 exit 0> worker=0 I, [2020-05-13T03:05:37.408230 #3494] INFO -- : reaped #<Process::Status: pid 3499 exit 0> worker=1 I, [2020-05-13T03:05:37.408304 #3494] INFO -- : master complete I, [2020-05-13T03:05:40.249754 #3629] INFO -- : Refreshing Gem list /home/shogo/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/bundler/gems/bootstrap-rubygem-ef343b781ca1/lib/bootstrap/version.rb:four: warning: already initialized constant Bootstrap::VERSION /home/shogo/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootstrap-sass-3.4.1/lib/bootstrap-sass/version.rb:two: warning: previous definition of VERSION was here /home/shogo/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/bundler/gems/bootstrap-rubygem-ef343b781ca1/lib/bootstrap/version.rb:five: warning: already initialized constant Bootstrap::BOOTSTRAP_SHA /home/shogo/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/bootstrap-sass-3.4.1/lib/bootstrap-sass/version.rb:three: warning: previous definition of BOOTSTRAP_SHA was here I, [2020-05-13T03:05:41.842262 #3629] INFO -- : unlinking existing socket=/var/www/rails/Portfolio/tmp/sockets/unicorn.sock I, [2020-05-13T03:05:41.842437 #3629] INFO -- : listening on addr=/var/www/rails/Portfolio/tmp/sockets/unicorn.sock fd=9 I, [2020-05-13T03:05:41.855398 #3629] INFO -- : master process ready I, [2020-05-13T03:05:41.859983 #3634] INFO -- : worker=1 ready I, [2020-05-13T03:05:41.861414 #3633] INFO -- : worker=0 ready
手がかりでも良いのでアドバイスをお願いします。
あなたの回答
tips
プレビュー