質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.46%
AWS Lambda

AWS Lambdaは、クラウド上でアプリを実行できるコンピューティングサービス。サーバーのプロビジョニングや管理を要せず複数のイベントに対してコードを実行します。カスタムロジック用いた他AWSサービスの拡張やAWSの規模やパフォーマンスを用いたバックエンドサービスを作成できます。

Amazon EC2

Amazon EC2は“Amazon Elastic Compute Cloud”の略称です。Amazon Web Services(AWS)の一部であり、仮想化されたWebサーバーのコンピュータリソースをレンタルできるサービスです。

Q&A

0回答

2177閲覧

【AWS・EC2のエラー】ElasticIPで404 Not Foundが表示されてしまう

NEMOTOSHOTA

総合スコア32

AWS Lambda

AWS Lambdaは、クラウド上でアプリを実行できるコンピューティングサービス。サーバーのプロビジョニングや管理を要せず複数のイベントに対してコードを実行します。カスタムロジック用いた他AWSサービスの拡張やAWSの規模やパフォーマンスを用いたバックエンドサービスを作成できます。

Amazon EC2

Amazon EC2は“Amazon Elastic Compute Cloud”の略称です。Amazon Web Services(AWS)の一部であり、仮想化されたWebサーバーのコンピュータリソースをレンタルできるサービスです。

0グッド

0クリップ

投稿2020/05/13 09:54

編集2020/05/13 09:54

設定を変えていないのに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

Portfolio.confの中身
イメージ説明

unicorn.confの中身
イメージ説明

手がかりでも良いのでアドバイスをお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.46%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問