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

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

新規登録して質問してみよう
ただいま回答率
85.48%
Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Ruby on Rails

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

Q&A

1回答

896閲覧

【heroku】アプリをデプロイできなくて困っています。

yuki1221

総合スコア6

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Ruby on Rails

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

0グッド

1クリップ

投稿2019/10/03 07:26

###概要

閲覧ありがとうございます。
Ruby on Railsで製作したアプリをherokuにデプロイしたのですが、application errorになってしまい、アクセスできません。
ローカル環境では問題なく動いています。
下記色々と試したのですが、なかなか解決できないため、何かヒントをいただけたら幸いです。

###試したこと

  • heroku restart
  • heroku ps:scale web=0 の後に heroku ps:scale web=1 を入力して再起動
  • ログに address already in use がいくつか見つかったので該当するポート番号?に対して以下を実行したのですが、実行できませんでした。(書き方が間違っている?)

kill -9 8015(各ポート番号)

  • failed to load command: puma とあったので、tmp以下にsocketsとpidsがないのかと思いましたが、作られていました。
  • procfileおよびpuma.rbは問題なく設定してあると思います。
  • こちらのサイトが一番自分の状況に近い感じだったのですが、いまいち解決に結びつきませんでした。(恥ずかしながらheroku run rails consoleでのエラーの見方がよくわかりません…)

https://stackoverflow.com/questions/13496827/heroku-deployment-error-h10-app-crashed

###コード
heroku logs  文字制限のためエラー以外の箇所を少し削除してあります。

app[web.1]: [4] * Version 3.12.1 (ruby 2.5.1-p57), codename: Llamas in Pajamas app[web.1]: [4] * Min threads: 5, max threads: 5 app[web.1]: [4] * Environment: production app[web.1]: [4] * Process workers: 2 app[web.1]: [4] * Preloading application heroku[web.1]: State changed from starting to crashed heroku[web.1]: Process exited with status 1 app[web.1]: [4] * Listening on tcp://0.0.0.0:8015 app[web.1]: bundler: failed to load command: puma (/app/vendor/bundle/ruby/2.5.0/bin/puma) app[web.1]: Errno::EADDRINUSE: Address already in use - bind(2) for "0.0.0.0" port 8015 app[web.1]: /app/vendor/bundle/ruby/2.5.0/gems/puma-3.12.1/lib/puma/binder.rb:273:in `initialize' app[web.1]: /app/vendor/bundle/ruby/2.5.0/bin/puma:23:in `load' app[web.1]: /app/vendor/bundle/ruby/2.5.0/bin/puma:23:in `<top (required)>' heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=fathomless-earth-90758.herokuapp.com request_id=19cafb03-8e87-4add-9899-261aa8656a6b fwd="150.246.14.84" dyno= connect= service= status=503 bytes= protocol=https heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=fathomless-earth-90758.herokuapp.com request_id=2ff7a60c-3aac-40a1-b05e-ae887771dde7 fwd="150.246.14.84" dyno= connect= service= status=503 bytes= protocol=https app[api]: Build started by user schecter_loomis@yahoo.co.jp heroku[web.1]: State changed from crashed to starting app[api]: Deploy c60751a5 by user schecter_loomis@yahoo.co.jp app[api]: Release v26 created by user schecter_loomis@yahoo.co.jp heroku[web.1]: Starting process with command `bundle exec puma -C config/puma.rb` app[api]: Build succeeded app[web.1]: [4] Puma starting in cluster mode... app[web.1]: [4] * Version 3.12.1 (ruby 2.5.1-p57), codename: Llamas in Pajamas app[web.1]: [4] * Min threads: 5, max threads: 5 app[web.1]: [4] * Environment: production app[web.1]: [4] * Process workers: 2 app[web.1]: [4] * Preloading application app[web.1]: [4] * Listening on tcp://0.0.0.0:47856 app[web.1]: bundler: failed to load command: puma (/app/vendor/bundle/ruby/2.5.0/bin/puma) app[web.1]: Errno::EADDRINUSE: Address already in use - bind(2) for "0.0.0.0" port 47856 app[web.1]: /app/vendor/bundle/ruby/2.5.0/gems/puma-3.12.1/lib/puma/binder.rb:273:in `initialize' app[web.1]: /app/vendor/bundle/ruby/2.5.0/bin/puma:23:in `load' app[web.1]: /app/vendor/bundle/ruby/2.5.0/bin/puma:23:in `<top (required)>' heroku[web.1]: State changed from starting to crashed heroku[web.1]: Process exited with status 1 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=fathomless-earth-90758.herokuapp.com request_id=bacb778d-c821-4a5a-b076-9f540bc67de3 fwd="150.246.14.84" dyno= connect= service= status=503 bytes= protocol=https heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=fathomless-earth-90758.herokuapp.com request_id=1f06bd5b-488c-4d64-ab6b-b4cae87e20f0 fwd="150.246.14.84" dyno= connect= service= status=503 bytes= protocol=https app[api]: Build started by user schecter_loomis@yahoo.co.jp app[api]: Deploy 485e98a3 by user schecter_loomis@yahoo.co.jp app[api]: Release v27 created by user schecter_loomis@yahoo.co.jp heroku[web.1]: State changed from crashed to starting heroku[web.1]: Starting process with command `bundle exec puma -C config/puma.rb` app[api]: Build succeeded app[web.1]: [4] Puma starting in cluster mode... app[web.1]: [4] * Version 3.12.1 (ruby 2.5.1-p57), codename: Llamas in Pajamas app[web.1]: [4] * Min threads: 5, max threads: 5 app[web.1]: [4] * Environment: production app[web.1]: [4] * Process workers: 2 app[web.1]: [4] * Preloading application heroku[web.1]: State changed from starting to up app[web.1]: [4] * Listening on tcp://0.0.0.0:18017 app[web.1]: [4] ! WARNING: Detected 1 Thread(s) started in app boot: app[web.1]: [4] ! #<Thread:0x0000556db0688fa8@/app/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:299 sleep> - /app/vendor/bundle/ruby/2.5.0/gems/activerecord-5.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:301:in `sleep' app[web.1]: [4] Use Ctrl-C to stop app[web.1]: [4] - Worker 0 (pid: 9) booted, phase: 0 app[web.1]: [4] - Worker 1 (pid: 13) booted, phase: 0 app[web.1]: [0ce52cc5-458a-48ca-b8e6-2d0500a552c3] Started GET "/" for 150.246.14.84 at app[web.1]: [0ce52cc5-458a-48ca-b8e6-2d0500a552c3] Processing by PostsController#index as HTML heroku[router]: at=info method=GET path="/" host=fathomless-earth-90758.herokuapp.com request_id=0ce52cc5-458a-48ca-b8e6-2d0500a552c3 fwd="150.246.14.84" dyno=web.1 connect=0ms service=399ms status=500 bytes=1827 protocol=https 2019-10-03T06:18:44.066217+00:00 app[web.1]: [0ce52cc5-458a-48ca-b8e6-2d0500a552c3] (1.9ms) SET NAMES utf8, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483 2019-10-03T06:18:44.079258+00:00 app[web.1]: [0ce52cc5-458a-48ca-b8e6-2d0500a552c3] Rendering posts/index.html.erb within layouts/application 2019-10-03T06:18:44.083784+00:00 app[web.1]: [0ce52cc5-458a-48ca-b8e6-2d0500a552c3] Post Load (2.1ms) SELECT `posts`.* FROM `posts` ORDER BY `posts`.`created_at` DESC LIMIT 5 OFFSET 0 2019-10-03T06:18:44.106305+00:00 app[web.1]: [0ce52cc5-458a-48ca-b8e6-2d0500a552c3] Rendered posts/_posts.html.erb (6.7ms) 2019-10-03T06:18:44.106401+00:00 app[web.1]: [0ce52cc5-458a-48ca-b8e6-2d0500a552c3] Rendered posts/index.html.erb within layouts/application (27.1ms) 2019-10-03T06:18:44.106703+00:00 app[web.1]: [0ce52cc5-458a-48ca-b8e6-2d0500a552c3] Completed 500 Internal Server Error in 386ms (ActiveRecord: 12.4ms) 2019-10-03T06:18:44.108125+00:00 app[web.1]: [0ce52cc5-458a-48ca-b8e6-2d0500a552c3] 2019-10-03T06:18:44.108183+00:00 app[web.1]: [0ce52cc5-458a-48ca-b8e6-2d0500a552c3] ActionView::Template::Error (Mysql2::Error: Table 'heroku_4f05d1bfc51893c.active_storage_attachments' doesn't exist: SHOW FULL FIELDS FROM `active_storage_attachments`): 2019-10-03T06:18:44.108379+00:00 app[web.1]: [0ce52cc5-458a-48ca-b8e6-2d0500a552c3] 1: <div class="post_container"> 2019-10-03T06:18:44.108382+00:00 app[web.1]: [0ce52cc5-458a-48ca-b8e6-2d0500a552c3] 2: <div class="image_box"> 2019-10-03T06:18:44.108384+00:00 app[web.1]: [0ce52cc5-458a-48ca-b8e6-2d0500a552c3] 3: <%= link_to post_path(post.id) do%> 2019-10-03T06:18:44.108389+00:00 app[web.1]: [0ce52cc5-458a-48ca-b8e6-2d0500a552c3] 4: <%= image_tag (post.image.variant(combine_options:{resize:"400x400^",crop:"400x400+0+0",gravity: :center}).processed) if post.image.attached? %> 2019-10-03T06:18:44.108392+00:00 app[web.1]: [0ce52cc5-458a-48ca-b8e6-2d0500a552c3] 5: <% end %> 2019-10-03T06:18:44.108394+00:00 app[web.1]: [0ce52cc5-458a-48ca-b8e6-2d0500a552c3] 6: </div> 2019-10-03T06:18:44.108396+00:00 app[web.1]: [0ce52cc5-458a-48ca-b8e6-2d0500a552c3] 7: <%= simple_format(post.text) %> 2019-10-03T06:18:44.108402+00:00 app[web.1]: [0ce52cc5-458a-48ca-b8e6-2d0500a552c3] 2019-10-03T06:18:44.108450+00:00 app[web.1]: [0ce52cc5-458a-48ca-b8e6-2d0500a552c3] app/views/posts/_posts.html.erb:4:in `block in _app_views_posts__posts_html_erb___3267599074679378641_46964804731020' 2019-10-03T06:18:44.108452+00:00 app[web.1]: [0ce52cc5-458a-48ca-b8e6-2d0500a552c3] app/views/posts/_posts.html.erb:3:in `_app_views_posts__posts_html_erb___3267599074679378641_46964804731020' 2019-10-03T06:18:44.108455+00:00 app[web.1]: [0ce52cc5-458a-48ca-b8e6-2d0500a552c3] app/views/posts/index.html.erb:11:in `block in _app_views_posts_index_html_erb___4290802838741419738_46964804753260' 2019-10-03T06:18:44.108457+00:00 app[web.1]: [0ce52cc5-458a-48ca-b8e6-2d0500a552c3] app/views/posts/index.html.erb:10:in `_app_views_posts_index_html_erb___4290802838741419738_46964804753260' 2019-10-03T06:18:44.422108+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=fathomless-earth-90758.herokuapp.com request_id=056477a6-55c9-43c3-b958-271a8f8c388f fwd="150.246.14.84" dyno=web.1 connect=0ms service=4ms status=200 bytes=143 protocol=https

puma.rb

workers Integer(ENV['WEB_CONCURRENCY'] || 2) threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5) threads threads_count, threads_count preload_app! rackup DefaultRackup port ENV['PORT'] || 3000 environment ENV['RACK_ENV'] || 'development' on_worker_boot do # Worker specific setup for Rails 4.1+ # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot ActiveRecord::Base.establish_connection end

procfile

web: bundle exec puma -C config/puma.rb

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

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

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

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

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

guest

回答1

0

heroku run rails db:migrate

したらどうでしょうか

もしくは

heroku run rails db:migrate:status

でmigrationの状態を確認してみると良いとおもいます

投稿2019/10/03 09:35

nakki

総合スコア9

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

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

yuki1221

2019/10/04 13:20

回答ありがとうございます。 migrateしてgit push heroku masterし直したところH=10 のアプリがクラッシュしてしまうエラーは消えました!ありがとうございます。 まだデプロイ自体はできてないのですが、これでまた一歩進めそうです。(template error undifined methodなのでおそらくアプリ自体の問題) 本当にありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

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

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

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問