1

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

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

4 Comments

That was my thought too - how can I check what it's using?
REDISTOGO_URL is set correctly in the config. And Python is pulling it in as well (if I import settings.REDIS_URL, it matches the Heroku config). Celery is in the same app.
Looking through my logs, it looks like Celery is reporting the correct broker (that same REDISTOGO_URL) in its configuration.
It's hard to tell from here. I would try to setup Celery according to their django documentation, put broker into settings.py and see if that helps.
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.