Python Celery socket.error: [Errno 61] Connection refused

I am using Celery 3.0 and have a configuration file as shown below.

celeryconfig.py

BROKER_URL = 'redis://localhost:6379/0' CELERY_RESULT_BACKEND = 'redis://localhost:6379/0' CELERY_TASK_SERIALIZER = 'json' CELERY_RESULT_SERIALIZER = 'json' CELERY_IMPORTS = ("tasks", ) CELERY_TASK_RESULT_EXPIRES = 300 

tasks.py

 import celery @celery.task def function(x,y): return x + y 

and function.py

 from tasks import function print function.delay(4,4).get() 

I run the application with the following command

 celeryd --loglevel=INFO --config=celeryconfig 

Everything is working fine so far. I work redis and celery and get answers.

But when I run the function command from another file called parallelizer,

I get a socket error,

  socket.error: [Errno 61] Connection refused 

My file as below

 from examples.dummy.tasks import function print function.delay(4,4).get() 

Any ideas?

+4
source share
3 answers

The problem was

I ran celeryconfig.py from a different path than my parallelizer.

When I moved celeryconfig.py to the same path using a parallelizer, it fixed the problem.

+1
source

I had the same problem, and the problem is that I missed this code in my __init __ project. py:

 from __future__ import absolute_import # This will make sure the app is always imported when # Django starts so that shared_task will use this app. from .celery import app as celery_app 

I hope this will be useful to someone there ...

+5
source

Had the same problem, eventually realized that the rabbitmq and redis were stopped.

On mac, if these services were installed via homebrew, you can check if these services are working by running the following command on the terminal,

 brew services list 

can restart services (if installed via brew )

 brew services restart rabbitmq brew services restart redis 
+5
source

All Articles