What's Actually Happening
Celery workers freeze and stop processing tasks. Tasks remain in pending state indefinitely.
The Error You'll See
```bash # Tasks stuck: $ celery -A myapp inspect active
No tasks in active queue, but pending tasks not processed ```
Why This Happens
- 1.Task blocking - Task waiting on lock or resource
- 2.Pool exhausted - All workers busy
- 3.Memory pressure - Worker OOM
- 4.Database lock - Long DB transaction
- 5.Circular task dependency - Tasks waiting on each other
Step 1: Check Worker Status
```bash # Check workers: celery -A myapp inspect active
# Check reserved: celery -A myapp inspect reserved
# Check stats: celery -A myapp inspect stats ```
Step 2: Restart Workers
```bash # Stop workers: pkill -f celery
# Start with concurrency: celery -A myapp worker --concurrency=4 --loglevel=info
# Or with pool: celery -A myapp worker --pool=prefork --concurrency=4 ```
Step 3: Fix Blocking Tasks
```python # BAD: Blocking task @celery_app.task def blocking_task(): time.sleep(3600) # Blocks for 1 hour
# GOOD: Use async or break up: @celery_app.task def non_blocking_task(): # Use smaller subtasks for chunk in chunks: process_chunk.delay(chunk) ```
Step 4: Set Time Limits
@celery_app.task(time_limit=300, soft_time_limit=240)
def my_task():
# Task will timeout after 5 minutes
passCelery Worker Checklist
| Check | Command | Expected |
|---|---|---|
| Active workers | inspect active | Tasks shown |
| Concurrency | inspect stats | > 0 |
| Memory usage | top | Normal |
Verify the Fix
celery -A myapp inspect active
# Output: Tasks processing normallyRelated Issues
- [Fix Celery Task Retry Loop](/articles/fix-celery-task-retry-loop)
- [Fix Celery Beat Schedule Not Running](/articles/fix-celery-beat-schedule-not-running)