Skip to content

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

Key points

  • PENDING is the default for unknown IDs.
  • A worker must consume the same queue the task was sent to.
  • One long task can block a worker with low concurrency.
  • Redis visibility timeouts cause tasks to run twice.

What is really happening

Celery reports PENDING unless a result says otherwise, and tasks only record STARTED if task_track_started is on. A task can be queued, reserved by a worker, running, or never have existed, and all look identical in status.

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.

Diagnose it

Ask the workers directly. A blank response means they are not reachable or not running.

bash
# 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 celery

Fixes

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.

Frequently asked questions

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.

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.