Redis::CannotConnectError: Connection refused - connect(2) for 127.0.0.1:6379

Hi everyone, I’m currently facing an issue with my Rails application, and I’m seeking some assistance to resolve it. I’ve tried running bundle update and bundle install to ensure all gems are up to date. I’ve verified my Redis configuration and made sure the server is running.

System Information: Ruby Version: 2.7 Rails Version: 5.2

When attempting to run my Rails application, I encounter the following error:

Puma caught this error: Connection refused - connect(2) for 127.0.0.1:6379 (Redis::CannotConnectError) /home/zacarias/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/socket.rb:1214:in __connect_nonblock' /home/zacarias/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/socket.rb:1214:in connect_nonblock’ /home/zacarias/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/socket.rb:56:in connect_internal' /home/zacarias/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/socket.rb:137:in connect’ /home/zacarias/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/socket.rb:642:in block in tcp' /home/zacarias/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/socket.rb:227:in each’ /home/zacarias/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/socket.rb:227:in foreach' /home/zacarias/.rvm/rubies/ruby-2.7.2/lib/ruby/2.7.0/socket.rb:632:in tcp’ /home/zacarias/.rvm/gems/ruby-2.7.2/gems/redis-client-0.19.1/lib/redis_client/ruby_connection.rb:117:in connect' /home/zacarias/.rvm/gems/ruby-2.7.2/gems/redis-client-0.19.1/lib/redis_client/ruby_connection.rb:49:in initialize’ /home/zacarias/.rvm/gems/ruby-2.7.2/gems/redis-client-0.19.1/lib/redis_client.rb:724:in new' /home/zacarias/.rvm/gems/ruby-2.7.2/gems/redis-client-0.19.1/lib/redis_client.rb:724:in block in connect’ /home/zacarias/.rvm/gems/ruby-2.7.2/gems/redis-client-0.19.1/lib/redis_client/middlewares.rb:12:in connect' /home/zacarias/.rvm/gems/ruby-2.7.2/gems/redis-client-0.19.1/lib/redis_client.rb:723:in connect’ /home/zacarias/.rvm/gems/ruby-2.7.2/gems/redis-client-0.19.1/lib/redis_client.rb:710:in raw_connection' /home/zacarias/.rvm/gems/ruby-2.7.2/gems/redis-client-0.19.1/lib/redis_client.rb:675:in ensure_connected’ /home/zacarias/.rvm/gems/ruby-2.7.2/gems/redis-client-0.19.1/lib/redis_client.rb:270:in call_v' /home/zacarias/.rvm/gems/ruby-2.7.2/gems/redis-5.0.8/lib/redis/client.rb:90:in call_v’ /home/zacarias/.rvm/gems/ruby-2.7.2/gems/redis-5.0.8/lib/redis.rb:152:in block in send_command' /home/zacarias/.rvm/gems/ruby-2.7.2/gems/redis-5.0.8/lib/redis.rb:151:in synchronize’ /home/zacarias/.rvm/gems/ruby-2.7.2/gems/redis-5.0.8/lib/redis.rb:151:in send_command' /home/zacarias/.rvm/gems/ruby-2.7.2/gems/redis-5.0.8/lib/redis/commands/strings.rb:97:in set’ /home/zacarias/.rvm/gems/ruby-2.7.2/gems/redis-namespace-1.11.0/lib/redis/namespace.rb:564:in wrapped_send' /home/zacarias/.rvm/gems/ruby-2.7.2/gems/redis-namespace-1.11.0/lib/redis/namespace.rb:521:in call_with_namespace’ /home/zacarias/.rvm/gems/ruby-2.7.2/gems/redis-namespace-1.11.0/lib/redis/namespace.rb:395:in block (2 levels) in <class:Namespace>' /home/zacarias/.rvm/gems/ruby-2.7.2/gems/rails_performance-1.2.0/lib/rails_performance/utils.rb:33:in save_to_redis’ /home/zacarias/.rvm/gems/ruby-2.7.2/gems/rails_performance-1.2.0/lib/rails_performance/models/request_record.rb:115:in save' /home/zacarias/.rvm/gems/ruby-2.7.2/gems/rails_performance-1.2.0/lib/rails_performance/rails/middleware.rb:65:in call!’ /home/zacarias/.rvm/gems/ruby-2.7.2/gems/rails_performance-1.2.0/lib/rails_performance/rails/middleware.rb:38:in call' /home/zacarias/.rvm/gems/ruby-2.7.2/gems/rails_performance-1.2.0/lib/rails_performance/rails/middleware.rb:17:in call!’ /home/zacarias/.rvm/gems/ruby-2.7.2/gems/rails_performance-1.2.0/lib/rails_performance/rails/middleware.rb:9:in call' /home/zacarias/.rvm/gems/ruby-2.7.2/gems/actionpack-5.2.8.1/lib/action_dispatch/middleware/executor.rb:14:in call’ /home/zacarias/.rvm/gems/ruby-2.7.2/gems/actionpack-5.2.8.1/lib/action_dispatch/middleware/static.rb:127:in call' /home/zacarias/.rvm/gems/ruby-2.7.2/gems/rack-2.2.6.3/lib/rack/sendfile.rb:110:in call’ /home/zacarias/.rvm/gems/ruby-2.7.2/gems/railties-5.2.8.1/lib/rails/engine.rb:524:in call' /home/zacarias/.rvm/gems/ruby-2.7.2/gems/puma-3.12.6/lib/puma/configuration.rb:227:in call’ /home/zacarias/.rvm/gems/ruby-2.7.2/gems/puma-3.12.6/lib/puma/server.rb:706:in handle_request' /home/zacarias/.rvm/gems/ruby-2.7.2/gems/puma-3.12.6/lib/puma/server.rb:476:in process_client’ /home/zacarias/.rvm/gems/ruby-2.7.2/gems/puma-3.12.6/lib/puma/server.rb:334:in block in run' /home/zacarias/.rvm/gems/ruby-2.7.2/gems/puma-3.12.6/lib/puma/thread_pool.rb:135:in block in spawn_thread’

After some reache I found the soluction, it seems that the project need Redis to start:

1 - Install the Redis: sudo apt-get install redis-server

2 - Them I run the commad above: redis-server

3 - After that a start my application normaly: rails s