title: How to setup an RQ worker on Heroku with RedisCloud using Flask
body: <p>I'm attempting to create a python rq worker on heroku for my flask app. The heroku documentation provides the following example code for creating a worker:</p>
  
  <p><a href="https://devcenter.heroku.com/articles/python-rq#create-a-worker" rel="nofollow">https://devcenter.heroku.com/articles/python-rq#create-a-worker</a></p>
  
  <pre><code>import os
  
  import redis
  from rq import Worker, Queue, Connection
  
  listen = ['high', 'default', 'low']
  
  redis_url = os.getenv('REDISTOGO_URL', 'redis://localhost:6379')
  
  conn = redis.from_url(redis_url)
  
  if __name__ == '__main__':
      with Connection(conn):
          worker = Worker(map(Queue, listen))
          worker.work()
  </code></pre>
  
  <p>Thing is: I am using RedisCloud and replacing REDISTOGO_URL with REDISCLOUD_URL is not working. It's fine loading locally but when I upload to heroku I am seeing in the logs it is still attempting to connect to localhost.</p>
  
  <pre><code>2015-02-25T00:11:53.445167+00:00 app[web.1]: ConnectionError: Error 111 connecting to localhost:6379. Connection refused.
  </code></pre>
  
  <p>The <a href="https://devcenter.heroku.com/articles/rediscloud#using-redis-from-python" rel="nofollow">RedisCloud documentation</a> only lists working with Python, not particularly flask, so the below code did not change my situation at all:</p>
  
  <pre><code># -*- coding: utf-8 -*-
  
  import os
  import urlparse
  
  import redis
  from rq import Worker, Queue, Connection
  
  listen = ['high', 'default', 'low']
  
  
  redis_url = urlparse.urlparse(os.environ.get('REDISCLOUD_URL', 'redis://localhost:6379'))
  
  conn = redis.from_url(redis_url.hostname)
  
  if __name__ == '__main__':
      with Connection(conn):
          worker = Worker(map(Queue, listen))
          worker.work()
  </code></pre>
  
  <p>i have confirmed that the REDISCLOUD_URL var is present on heroku via:</p>
  
  <pre><code>$heroku config:get REDISCLOUD_URL
  </code></pre>
  
  <p>in format:</p>
  
  <pre><code>http://rediscloud:password@hostname:port
  </code></pre>
  
  <p>I can find no documentation on what the redis.from_url() function does or what parameters it accepts.</p>
  
  <p>What am I missing here to get this worker to look to the server var for heroku and not localhost?</p>