Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8218905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:57:54+00:00 2026-06-07T12:57:54+00:00

A Rails 3.2.6 application running as a ‘web’ Heroku process is connecting to Redis

  • 0

A Rails 3.2.6 application running as a ‘web’ Heroku process is connecting to Redis using the ENV[“REDISTOGO_URL”] environment variable:

irb(main):002:0> Redis.current
=> #<Redis client v2.2.2 connected to redis://xxx.redistogo.com:1234/0 (Redis v2.4.11)>

—– /initializers/redis.rb

if Rails.env.development?
  Redis.current = Redis.new
elsif Rails.env.test?
  Redis.current = Redis.new
elsif Rails.env.production?
  uri = URI.parse(ENV["REDISTOGO_URL"])
  Redis.current = Redis.new(:host => uri.host, :port => uri.port, :password => uri.password)
end

A ruby daemon ‘streaming’ process runs as a secondary worker:

—– Procfile

web: bundle exec rails server thin -p $PORT -e $RACK_ENV
worker: bundle exec rake jobs:work
streaming: RAILS_ENV=production ruby bin/streaming.rb start

However, the streaming process is crashing when it calls methods in the main Rails application that connect with Redis – even though the streaming process supposed to be loading the same redis.rb initializer as the ‘web’ Rails application process.

—– /bin/streaming_ctl.rb

# encoding: UTF-8

require "rubygems"
require "bundler/setup"
require "daemons"

Daemons.run(File.expand_path("../streaming.rb", __FILE__))

—– /bin/streaming.rb

# encoding: UTF-8

# TODO: set rails env in init script
ENV["RAILS_ENV"] ||= "production"

# load rails environment
require File.expand_path('../../config/environment', __FILE__)

logger = ActiveSupport::BufferedLogger.new(File.expand_path("./../../log/streaming.log", __FILE__))

Streaming.start
logger.info("\nStarting streaming in #{Rails.env.to_s} mode.")

Why is the streaming process/worker using the default Redis host and port?

[streaming.1]: /app/vendor/bundle/ruby/1.9.1/gems/redis-2.2.2/lib/redis/client.rb:236:in `rescue in establish_connection': Connection refused - Unable to connect to Redis on 127.0.0.1:6379 (Errno::ECONNREFUSED)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:57:56+00:00Added an answer on June 7, 2026 at 12:57 pm

    Switching from “Redis.current” in /initializer/redis.rb and using a “$redis” variable convention instead (as illustrated here http://jimneath.org/2011/03/24/using-redis-with-ruby-on-rails.html) fixed the connection problem.

    The app was using redis gem version 2.2.2 at the time. It appears as though the Redis.current in this gem version won’t be consistent across ‘web’ and ‘worker’ processes because Heroku runs these processes on separate threads. The documentation on the gem repo suggests that updating to gem to >= version 3 will enable Redis.current to run in multi-threaded environments:

    https://github.com/redis/redis-rb/blob/master/CHANGELOG.md#300

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're using EngineYard Cloud to deploy our Ruby on Rails application. We are running
I am trying to get my rails application running on my web server, but
I'm running a rails application on EC2, and I'm using mongoHQ as DBMS. I've
I am running my tests for a rails application using test/unit and capybara. I
When running unit and functional tests using rake, on a rails application, I notice
What is the recommended setup for a Rails application running in the production environment
In my rails application (running on a mac), I'm using a gem called pony.
I'm using Apache + passenger for my rails application, The application is running fine
On a Postgres backed Rails application running on Heroku I am trying to add
I am working on a web application running on Rails 2.1 version. I would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.