How To Restart Celery Worker

Your Cool Home is supported by its readers. Please assume all links are affiliate links. If you purchase something from one of our links, we make a small commission from Amazon. Thank you!

You can restart a celery worker by stopping the current process and starting it again with the same command you used originally.
 
It sounds simple, and honestly, it usually is.
 
But there are a few different ways to restart a celery worker depending on how you’re running it.
 
Maybe you started it manually in a terminal, or perhaps it’s managed by systemd, supervisor, or Docker.
 
The method you use to restart celery worker changes based on your setup.
 
In this post, we’ll walk through how to restart a celery worker in several common scenarios.
 
We’ll also cover why you might need to restart a celery worker and how to do it without disrupting your tasks.
 
Let’s dive in.
 

Why You Might Need to Restart a Celery Worker

There are plenty of reasons to restart a celery worker, and knowing them helps you decide when it’s actually necessary.
 
Here are the most common situations where a restart makes sense.
 

1. Code Changes Won’t Apply Without a Restart

Celery workers load your task code into memory when they start.
 
If you update a task function, the running celery worker won’t pick up those changes automatically.
 
You have to restart celery worker processes to load the new code.
 
This is probably the number one reason developers restart a celery worker during development.
 

2. Memory Leaks or Stuck Tasks

Sometimes a celery worker gets stuck on a task that never finishes.
 
Other times, memory usage creeps up over days or weeks.
 
Restarting the celery worker clears that memory and kills any hung processes.
 
It’s a simple fix that solves a surprising number of weird issues.
 

3. Configuration Changes

If you change your celery configuration, like the concurrency level or the broker URL, the worker needs a restart to apply it.
 
A running celery worker won’t reload config files on its own.
 
So restart celery worker anytime your settings change.
 

How to Restart Celery Worker Manually

If you started your celery worker by hand in a terminal, restarting it is straightforward.
 
Here’s the process step by step.
 

1. Find the Running Worker Process

First, you need to locate the celery worker that’s running.
 
You can use a command like ps aux | grep celery to list all celery processes.
 
Look for the main worker process, which usually shows the command you used to start it.
 

2. Stop the Celery Worker Gracefully

The best way to stop a celery worker is with a warm shutdown.
 
You can send a TERM signal to the process, and celery will finish any tasks currently running before it exits.
 
Just run kill -TERM <pid> using the process ID you found.
 
This ensures no tasks are lost mid-execution.
 

3. Start the Celery Worker Again

Once the process has stopped, simply run your original start command again.
 
Something like celery -A myproject worker –loglevel=info will bring it back up.
 
And that’s it, you’ve just restarted your celery worker manually.
 

Restart Celery Worker with Systemd or Supervisor

In production, most people don’t run celery workers by hand.
 
They use a process manager like systemd or supervisor to keep things running.
 
Here’s how to restart celery worker in each case.
 

1. Restarting with Systemd

If your celery worker runs as a systemd service, restarting is a single command.
 
Just run sudo systemctl restart celery.service and systemd handles the rest.
 
It stops the old process and starts a fresh one automatically.
 
You can check the status with sudo systemctl status celery.service to confirm it’s running.
 

2. Restarting with Supervisor

Supervisor users can restart a celery worker with supervisorctl restart celery.
 
This tells supervisor to stop and start the celery worker program you defined in your config.
 
It’s clean, fast, and keeps your worker managed.
 
Again, this is a graceful restart, so running tasks finish before the worker shuts down.
 

3. Restarting a Celery Worker in Docker

If your celery worker runs inside a Docker container, you restart the container itself.
 
Run docker restart <container_name> and Docker stops and starts the container.
 
The celery worker inside will restart along with it.
 
Just make sure your container is set to run the worker as its main process.
 

Tips to Restart Celery Worker Without Losing Tasks

Restarting a celery worker doesn’t have to mean losing tasks.
 
Here are a few tips to keep things smooth.
 

1. Always Use a Warm Shutdown

A warm shutdown lets the worker finish its current tasks before exiting.
 
Avoid using kill -9 unless you absolutely have to, since it kills tasks instantly.
 
Graceful restarts keep your data safe.
 

2. Restart One Worker at a Time

If you run multiple celery workers, restart them one by one.
 
This way, other workers keep processing tasks while one is down.
 
It avoids downtime and keeps your queue moving.
 

3. Monitor After the Restart

After you restart celery worker processes, check the logs.
 
Make sure tasks are being picked up and completed as expected.
 
A quick look at your monitoring tools can save you from surprises later.
 

So, How Do You Restart a Celery Worker?

You can restart a celery worker by stopping the current process and starting it again with the same command you used originally.
 
Whether you run it manually, through systemd, supervisor, or Docker, the goal is the same.
 
Stop the worker gracefully, then start it back up.
 
Use a warm shutdown whenever possible, restart workers one at a time, and monitor things afterward.
 
With these steps, you can restart celery worker processes confidently and keep your task queue running smoothly.