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

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

新規登録して質問してみよう
ただいま回答率
85.47%
Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

Q&A

解決済

1回答

1113閲覧

AWS,本番環境でRailsを起動させたい。

bohzu13

総合スコア8

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

0グッド

0クリップ

投稿2020/06/27 09:03

##エラー内容
本番環境、ブラウザで開ません。
イメージ説明

##ターミナルで確認

log/unicorn.stderr.log

ターミナル(EC2サーバ)

I, [2020-06-27T08:09:55.934822 #15291] INFO -- : Refreshing Gem list I, [2020-06-27T08:09:57.926836 #15291] INFO -- : listening on addr=0.0.0.0:3000 fd=10 E, [2020-06-27T08:09:57.927317 #15291] ERROR -- : Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) (Mysql2::Error::ConnectionError) /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:90:in `connect' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:90:in `initialize' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/mysql2_adapter.rb:22:in `new' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/mysql2_adapter.rb:22:in `mysql2_connection' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:830:in `new_connect ion' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:874:in `checkout_ne w_connection' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:853:in `try_to_chec kout_new_connection' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:814:in `acquire_con nection' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:538:in `checkout' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:382:in `connection' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.4.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:1033:in `retrieve_connection' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.4.3/lib/active_record/connection_handling.rb:118:in `retrieve_connection' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activerecord-5.2.4.3/lib/active_record/connection_handling.rb:90:in `connection' config/unicorn.rb:27:in `block in reload' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:543:in `spawn_missing_workers' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:142:in `start' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `<top (required)>' /home/ec2-user/.rbenv/versions/2.5.1/bin/unicorn_rails:23:in `load' /home/ec2-user/.rbenv/versions/2.5.1/bin/unicorn_rails:23:in `<top (required)>' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `load' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:63:in `kernel_load' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/cli/exec.rb:28:in `run' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/cli.rb:476:in `exec' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor.rb:399:in `dispatch' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/cli.rb:30:in `dispatch' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/vendor/thor/lib/thor/base.rb:476:in `start' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/cli.rb:24:in `start' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/exe/bundle:46:in `block in <top (required)>' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/lib/bundler/friendly_errors.rb:123:in `with_friendly_errors' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/bundler-2.1.4/exe/bundle:34:in `<top (required)>' /home/ec2-user/.rbenv/versions/2.5.1/bin/bundle:23:in `load' /home/ec2-user/.rbenv/versions/2.5.1/bin/bundle:23:in `<main>' I, [2020-06-27T08:17:43.387230 #15434] INFO -- : Refreshing Gem list I, [2020-06-27T08:17:45.077710 #15434] INFO -- : listening on addr=0.0.0.0:3000 fd=10 I, [2020-06-27T08:17:45.083248 #15434] INFO -- : master process ready I, [2020-06-27T08:17:45.090798 #15443] INFO -- : worker=0 ready bundler: failed to load command: unicorn_rails (/home/ec2-user/.rbenv/versions/2.5.1/bin/unicorn_rails) ArgumentError: Already running on PID:15434 (or pid=/var/www/bicycle2/tmp/pids/unicorn.pid is stale) /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:205:in `pid=' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:137:in `start' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `<top (required)>' /home/ec2-user/.rbenv/versions/2.5.1/bin/unicorn_rails:23:in `load' /home/ec2-user/.rbenv/versions/2.5.1/bin/unicorn_rails:23:in `<top (required)>' bundler: failed to load command: unicorn_rails (/home/ec2-user/.rbenv/versions/2.5.1/bin/unicorn_rails) ArgumentError: Already running on PID:15434 (or pid=/var/www/bicycle2/tmp/pids/unicorn.pid is stale) /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:205:in `pid=' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:137:in `start' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `<top (required)>' /home/ec2-user/.rbenv/versions/2.5.1/bin/unicorn_rails:23:in `load' /home/ec2-user/.rbenv/versions/2.5.1/bin/unicorn_rails:23:in `<top (required)>' bundler: failed to load command: unicorn_rails (/home/ec2-user/.rbenv/versions/2.5.1/bin/unicorn_rails) ArgumentError: Already running on PID:15434 (or pid=/var/www/bicycle2/tmp/pids/unicorn.pid is stale) /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:205:in `pid=' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:137:in `start' /home/ec2-user/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `<top (required)>' /home/ec2-user/.rbenv/versions/2.5.1/bin/unicorn_rails:23:in `load' /home/ec2-user/.rbenv/versions/2.5.1/bin/unicorn_rails:23:in `<top (required)>' (END)

##試した事、確認
config/database.ymを本番環境に編集して
ブランチで作業していたのでマージした。

##環境
ruby
rails
MySQL
AWS

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

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

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

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

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

yu_1985

2020/06/27 16:04

HTTPSでアクセスできるような設定をちゃんと実施してますか?
guest

回答1

0

ベストアンサー

httpだからです。

解決策4つ

  1. ブラウザーによっては「それは承知だから、アクセスさせてくれ」というのができるものがあります。お使いのがそうでしたら試してください
  2. AWSのELB(ALBともいう?)を使って、サーバーはhttpのままでもhttpsでアクセス出来るようにする 方法を取る

3)オレオレ認証なサーバー認証keyを作ってとりあえずhttps化してみる
4) きちんと正規のサーバー認証keyを取得して、https化する

投稿2020/06/27 10:46

winterboum

総合スコア23376

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

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

bohzu13

2020/06/27 11:23

回答ありがとうございます。 とりあえず 1番のプラウザで許可をやってみたのですが このサイトは安全に接続できません 3.113.92.102 から無効な応答が送信されました。 ERR_SSL_PROTOCOL_ERROR と、表示されました。 4) きちんと正規のサーバー認証keyを取得して、https化するをした方がいいのですか?
winterboum

2020/06/27 11:27

ERR_SSL_PROTOCOL_ERROR となってるってことは、「安全では無いのは承知だからアクセスさせてくれ」に成っていないですね。ブラウザーは何でしょう? で、 4の経験がお有りでしたらそれが良いかも。 でないなら、2も候補ですね
bohzu13

2020/06/28 05:07

Google Chromeで開きました。 左上更新ボタンのすぐ右でブロックだったのを許可に変更してなりました。 2番の参考になりそうなのがあったのでやってみます。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.47%

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

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

質問する

関連した質問