Mike
Mike

Reputation: 371

Connection refused for Redis on Heroku

I'm trying to set up Redis on Heroku as a backend for Celery. I have it working locally but on Heroku, I get this error (after the celery task completes): ConnectionError: Error 111 connecting localhost:6379. Connection refused.

From what I can tell from other answers, that would indicate that the redis server isn't online, though the REDISTOGO_URL seems to be configured properly.

In settings.py:

REDIS_URL = os.getenv('REDISTOGO_URL', 'redis://localhost:6379/0')

In tasks.py:

from celery import Celery
celery = Celery('tasks', backend=settings.CELERY_RESULT_BACKEND, broker=settings.REDIS_URL)

Versions:

celery==3.0.5
celery-with-redis==3.0
django-celery==3.0.4
kombu==2.3.2
redis==2.6.0

Upvotes: 1

Views: 5326

Answers (2)

Mike
Mike

Reputation: 371

Found the problem. I had the celery backend configured to the string 'redis' rather than the REDIS_URL.

What I had:

CELERY_RESULT_BACKEND = 'redis'

What it should be:

CELERY_RESULT_BACKEND = REDIS_URL

Dmitry - appreciate your help.

Upvotes: 1

Dmitry Shevchenko
Dmitry Shevchenko

Reputation: 32394

Looks like you're not using REDISTOGO_URL, since the error message states localhost

Try to check:

  1. heroku config, just to check that REDISTOGO_URL is set in config
  2. Go to shell on heroku (like this) and see if python gets url correctly

Do you run celery on the same app, if not check that other server's config.

Upvotes: 2

Related Questions