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

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

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

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

Heroku

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

Redis

Redisは、オープンソースのkey-valueデータストアで、NoSQLに分類されます。すべてのデータをメモリ上に保存するため、処理が極めて高速です。

Q&A

解決済

1回答

1046閲覧

Heroku デプロイ時にRedisのエラー

lwbox

総合スコア1

Ruby on Rails 6

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

Heroku

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

Redis

Redisは、オープンソースのkey-valueデータストアで、NoSQLに分類されます。すべてのデータをメモリ上に保存するため、処理が極めて高速です。

0グッド

0クリップ

投稿2021/04/01 04:43

前提

オリジナルのアプリケーションを作ったあと、herokuにデプロイしたのですが、Application Errorが出て解決できません。
Rails 6.0.3.5
ruby 2.6.5

エラー文

Terminal

1% heroku logs -t 2. 3. 4. 52021-04-01T03:59:17.481099+00:00 app[web.1]: /app/vendor/bundle/ruby/2.6.0/gems/redis-4.2.5/lib/redis/client.rb:367:in `rescue in establish_connection': Error connecting to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED) (Redis::CannotConnectError) 62021-04-01T03:59:17.481103+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.6.0/gems/redis-4.2.5/lib/redis/client.rb:348:in `establish_connection' 7. 8. 9. 10#省略 11. 12. 13. 142021-04-01T03:59:17.692297+00:00 heroku[web.1]: State changed from up to crashed 152021-04-01T03:59:22.552408+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=sports-blogs.herokuapp.com request_id=4bf48790-530c-46d8-aaae-eed619a680db fwd="126.99.229.42" dyno= connect= service= status=503 bytes= protocol=https 162021-04-01T03:59:22.570959+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=sports-blogs.herokuapp.com request_id=7d0d1b14-f206-43c3-8926-ceb8fbd76506 fwd="126.99.229.42" dyno= connect= service= status=503 bytes= protocol=https 172021-04-01T03:59:22.629772+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=sports-blogs.herokuapp.com request_id=6ca6af83-cbdc-4174-8dd0-6a763e59c980 fwd="126.99.229.42" dyno=web.1 connect=5001ms service= status=503 bytes= protocol=https 182021-04-01T03:59:23.067751+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=sports-blogs.herokuapp.com request_id=b7107dad-b6db-4cba-87a6-94b07d87dbde fwd="126.99.229.42" dyno= connect= service= status=503 bytes= protocol=https

試したこと

https://github.com/bodrovis/Sitepoint-source/issues/16
方法としてはいまいちしっかりした情報が他に載っておらず、こちらを参考にやってみたのですが全然変わらず困っています。

ソースコード

config/cable.yml

development: # adapter: redis # url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> # channel_prefix: sports_junkies_development adapter: async test: adapter: test production: adapter: redis url: <%= ENV["REDISCLOUD_URL"] %> # <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> channel_prefix: sports_junkies_production

Gemfileもとりあえず載せておきます。
Gemfile

source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby '2.6.5' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 6.0.0' # Use mysql as the database for Active Record gem 'mysql2', '>= 0.4.4' # Use Puma as the app server gem 'puma', '~> 3.11' # Use SCSS for stylesheets gem 'sass-rails', '~> 5' # Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker gem 'webpacker', '~> 4.0' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks gem 'turbolinks', '~> 5' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.7' # Use Redis adapter to run Action Cable in production # gem 'redis', '~> 4.0' # Use Active Model has_secure_password # gem 'bcrypt', '~> 3.1.7' # Use Active Storage variant # gem 'image_processing', '~> 1.2' # Reduces boot times through caching; required in config/boot.rb gem 'bootsnap', '>= 1.4.2', require: false gem 'redis', '~> 4.0' group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] end group :development do # Access an interactive console on exception pages or by calling 'console' anywhere in the code. gem 'web-console', '>= 3.3.0' gem 'listen', '>= 3.0.5', '< 3.2' # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring' gem 'spring-watcher-listen', '~> 2.0.0' end group :test do # Adds support for Capybara system testing and selenium driver gem 'capybara', '>= 2.15' gem 'selenium-webdriver' # Easy installation and use of web drivers to run system tests with browsers gem 'webdrivers' gem 'rspec-rails', '~> 4.0.0' gem 'factory_bot_rails' gem 'faker' end group :production do gem 'unicorn', '5.4.1' end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] gem 'devise' gem 'pry-rails' gem 'mini_magick' gem 'image_processing', '~> 1.2' gem 'acts-as-taggable-on', '~> 7.0' gem 'bootstrap', '~> 5.0.0.beta1' gem "optimism", "~> 0.4.1" gem "aws-sdk-s3", require: false

どなたか解決方法わかる方いらっしゃいましたらぜひアドバイスの方よろしくお願いします。

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

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

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

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

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

guest

回答1

0

自己解決

この問題の根本な解決方法ではないので、参考にならない方もいらっしゃるかもしれませんがとりあえず本番環境で正常に動くようになったので記載します。
解決方法が全然思い浮かばなかったのでredisを削除しました。
まず、

Terminal

1% brew services stop redis

でサーバーをストップ。
もう一つ、

Terminal

1% bundle exec gem uninstall redis

を実行し、成功したらgemfileに記載してあるgemも削除して、bundle。
最後にcommit → pushして、

Terminal

1% git push heroku master

を実行して動かしたら、正常に作動しました。
これでもいいと思うのですが、根本的に何が間違っているのかわかる方がいらっしゃいましたらアドバイスの方よろしくお願いします。

追加で cable.yml も変えました。

production: adapter: redis url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> channel_prefix: sports_junkies_production

投稿2021/04/01 10:30

編集2021/04/03 13:59
lwbox

総合スコア1

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問