Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error 111 connecting to localhost:6379. Connection refused. Django Heroku

I am able to run redis locally and everything works.

However when I deploy to heroku I get this error:

Error 111 connecting to localhost:6379. Connection refused.  

I have set up a Procfile with...

web: gunicorn odb.wsgi --log-file - worker: python worker.py 

I have a worker.py file...

import os import urlparse from redis import Redis from rq import Worker, Queue, Connection  listen = ['high', 'default', 'low']  redis_url = os.getenv('REDISTOGO_URL') if not redis_url:     raise RuntimeError('Set up Redis To Go first.')  urlparse.uses_netloc.append('redis') url = urlparse.urlparse(redis_url) conn = Redis(host=url.hostname, port=url.port, db=0, password=url.password)  if __name__ == '__main__': with Connection(conn):     worker = Worker(map(Queue, listen))     worker.work() 

A REDISTOGO_URL variable appears in the heroku config.

Redis to go is an installed add-on for my app.

Does REDISTOGO_URL have to be defined in settings.py? Why is heroku trying to connect to the local host when it is not even defined in worker.py?

like image 871
John Waller Avatar asked Mar 18 '16 15:03

John Waller


1 Answers

May be not directly related to your question but I was facing same error and it turn out that on my system redis-server package was not installed.

Problem was resolved with,

Ubuntu: sudo apt-get install redis-server

Cent OS: sudo yum install redis

like image 166
shrishinde Avatar answered Sep 22 '22 02:09

shrishinde