Troubleshooting guide
Celery tasks stuck in PENDING: how to fix it
PENDING in Celery often just means "unknown": it is also the status for a task ID nobody has seen. So first establish whether workers received it.
3 min read10 sectionsUpdated
On this page
Common causes
- Queue mismatch: tasks routed to a queue that no worker consumes.
- Unregistered task: the worker did not import the module.
- Workers busy on long tasks.
- Prefetching that holds tasks on a worker that is busy.
- Different broker or result backend between producer and worker.
- Workers frozen on a hung network call with no timeout.
# Are workers alive, and which queues do they read?
celery -A app inspect ping
celery -A app inspect active_queues
# Current work, reserved tasks and registered names
celery -A app inspect active
celery -A app inspect reserved
celery -A app inspect registered
# Depth of the default Redis queue
redis-cli LLEN celeryFixes
Start workers with the right queues: celery -A app worker -Q default,emails. Add every task module to include or use autodiscovery. Keep long tasks on a dedicated queue and worker. Use worker_prefetch_multiplier = 1 for long tasks. Set task_time_limit and socket timeouts to stop hung tasks. With Redis as the broker, set visibility_timeout above your longest ETA or task duration, or tasks will be delivered again.
Acks and duplicates
By default, Celery acknowledges a task just before running it, so a worker crash loses it. Setting task_acks_late = True acknowledges after completion, which means tasks can run more than once after a crash. Either choice requires a decision, and late acks need idempotent tasks. Pair it with task_reject_on_worker_lost if you want the task requeued in that case. Check tasks scheduled with long ETAs too: they sit in worker memory, not in the queue, so a queue that seems empty does not always mean no work is pending.
Catch it automatically
Watch queue length and the age of the oldest task. Use a heartbeat monitor for periodic tasks, so missed Celery Beat schedules alert you. Tracing links a task to the request that created it.
Why is my task always PENDING?
A worker may never have received it, or result tracking is off. Check inspect active_queues and task_track_started.
Should I use Redis or RabbitMQ as broker?
Both work. RabbitMQ has stronger delivery semantics, and Redis is simpler to run.
How can I stop a stuck task?
Use celery control revoke with terminate, and set time limits to prevent recurrences.
Related reading
- Kubernetes pod stuck in Pending: how to fix it: Fix Kubernetes pods stuck in Pending: insufficient CPU or memory, taints, node selectors and unbound PersistentVolumeClaims, using scheduler events.
- 501 Not Implemented: how to fix it: Fix 501 Not Implemented: unsupported HTTP methods, servers and proxies that do not support PATCH or WebDAV, and how it differs from 405 and 500.
- "DNS server not responding": how to fix it: Fix "DNS server not responding" on Windows and Mac: restart the router, flush DNS, switch to 1.1.1.1 or 8.8.8.8, and check adapters, VPNs and firewalls.
- Kubernetes pod stuck in Terminating: how to fix it: Fix pods stuck in Terminating: finalizers, unreachable nodes, stuck volumes and processes that ignore SIGTERM, and when force deletion is safe to use.
- 404 Not Found: how to find and fix broken pages: Find and fix 404 errors: broken internal links, moved pages, case-sensitive paths and soft 404s, with commands and advice on what actually affects SEO.
- DNS_PROBE_FINISHED_NXDOMAIN: fix it for your domain: What DNS_PROBE_FINISHED_NXDOMAIN means, how to check your domain and DNS records, the usual causes such as expiry and typos, and how to monitor DNS.
Watch your own site and services with VitalRix
Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.