EthioDeploy
DocsPricingDomainsBlogToolsChangelog
Deploy guides/Django + Celery

Deploy Django with Celery and Redis

Deploy the Django app as the project, add a Redis addon, then add the Celery worker as a Background worker service with the start command celery -A myproject worker --concurrency 2. The service runs from the same repo and gets the project's env vars, including REDIS_URL. Run beat as a second worker service, or inside the worker with -B when there is only one worker. Services need Pro or Business. Redis keeps no data on disk here, so keep anything you can't lose in Postgres.

Last updated November 29, 2026

What we run by default
Detected by
manage.py (the web service), your start command (each Celery service)
Install
pip install -r requirements.txt
Build
none by default (add collectstatic on the web service)
Start
migrate + gunicorn (web), celery -A myproject worker (worker service)

These run automatically, so leave the command fields blank. Only override them in Settings → Build if you need something different.

Fix this first: Set --concurrency yourself

Celery starts one worker process per CPU it sees, and it sees every core of the server, not the one CPU your container is allowed. In our test under a one-CPU limit on an 8-core machine, Celery 5.7 started 8 processes, each a full copy of Django. Pass --concurrency 2 (or --concurrency auto on Celery 5.7, which reads the container's limit) so the worker fits in its memory.

What runs where

A Django app with Celery is three or four processes from one repo. On EthioDeploy each one is a service in the same project:

ProcessRuns asStart command
DjangoThe project itself (web service)Default: migrate, then gunicorn
Celery workerBackground worker servicecelery -A myproject worker
Celery beat (optional)Background worker servicecelery -A myproject beat
RedisRedis addonSets REDIS_URL
PostgresPostgres addonSets DATABASE_URL

Services share the project's repo, branch, env vars and addons, and run on the same server, each in its own container. Set up the Django app first with the Django guide (settings, static files, ALLOWED_HOSTS); this page adds Celery to it.

Add Celery to the Django project

Add Celery with its Redis extra to requirements.txt. The extra matters: with plain celery and redis, Celery 5.7 crashes at start with No module named 'packaging'.

django
gunicorn
whitenoise
dj-database-url
psycopg[binary]
celery[redis]

Create myproject/celery.py next to settings.py, as in Celery's Django guide:

import os

from celery import Celery

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")

app = Celery("myproject")
app.config_from_object("django.conf:settings", namespace="CELERY")
app.autodiscover_tasks()

Load it in myproject/__init__.py, so @shared_task uses this app:

from .celery import app as celery_app

__all__ = ("celery_app",)

Tasks go in a tasks.py in any installed app:

# shop/tasks.py
from celery import shared_task

from .models import Order


@shared_task
def send_receipt(order_id):
    order = Order.objects.get(pk=order_id)
    ...  # send the email

# in a view: send_receipt.delay(order.pk)

Pass ids, not model instances: the task runs later in another process and should read the current row.

Celery settings

With namespace="CELERY", Celery reads every setting that starts with CELERY_ from settings.py:

CELERY_BROKER_URL = os.environ["REDIS_URL"]
CELERY_BROKER_CONNECTION_RETRY_ON_STARTUP = True

# No result backend: most tasks write their result to Postgres anyway.
CELERY_TASK_IGNORE_RESULT = True

# Acknowledge after the task finishes, so a task cut off by a restart runs again.
CELERY_TASK_ACKS_LATE = True
CELERY_WORKER_PREFETCH_MULTIPLIER = 1

# Recycle a worker process once it passes ~200 MB (the value is in KiB).
CELERY_WORKER_MAX_MEMORY_PER_CHILD = 200_000

CELERY_TIMEZONE = "UTC"

REDIS_URL is set by the Redis addon and reaches every service. With CELERY_TASK_ACKS_LATE, make tasks safe to run twice: a task that was halfway through when the worker stopped starts again from the beginning.

If you do need results (to poll a task's status from the browser, or for chords), store them in Postgres with django-celery-results rather than in Redis, for the reason in the Redis section below.

Add Redis and the worker service

  1. Deploy the Django app as a normal project and add a Postgres addon, as in the Django guide.
  2. Add a Redis addon to the same project. It sets REDIS_URL.
  3. Open the project's Services tab, click Add service, pick Background worker, name it worker and set the start command:
    celery -A myproject worker --loglevel INFO --concurrency 2

Or from the CLI, in the linked repo:

ethiodeploy services add worker --start "celery -A myproject worker --loglevel INFO --concurrency 2"
ethiodeploy logs -p <project-slug>-worker

The worker builds from the same repo and deploys right away. In its logs, celery@… ready. means it connected to Redis. A worker has no port and no health check: a deploy counts as healthy if the process is still running a few seconds after it starts. A worker that can't reach Redis keeps retrying and stays “running”, so read the log after the first deploy.

Migrations stay in the web service's start command. The worker's own start command replaces the default, so it never runs migrate.

Celery beat for periodic tasks

Define the schedule in settings.py:

from celery.schedules import crontab

CELERY_BEAT_SCHEDULE = {
    "clean-expired-carts": {
        "task": "shop.tasks.clean_expired_carts",
        "schedule": crontab(minute=0, hour="*/6"),
    },
}

Then add a second worker service, named beat, with the start command:

celery -A myproject beat --loglevel INFO

Beat only puts tasks on the queue; the worker runs them. Run exactly one beat. Two beats send every task twice, and that's why beat belongs in its own worker service: a worker deploy stops the old container before it starts the new one, so two beats never overlap.

With a single worker you can save a container and run beat inside it with -B. Celery's docs say that's fine when you'll never run more than one worker, and not recommended for production:

celery -A myproject worker -B --loglevel INFO --concurrency 2

Beat keeps its last-run times in a celerybeat-schedule file inside the container, which a deploy replaces. For schedules you edit in the Django admin and that live in Postgres, use django-celery-beat and start beat with --scheduler django_celery_beat.schedulers:DatabaseScheduler. Other ways to run scheduled jobs are in cron jobs on a PaaS.

Concurrency and memory

Each service gets its own container with the plan's limits: 1 GB of memory and one CPU on Pro, 2 GB and two CPUs on Business. Celery's default prefork pool runs one process per concurrency slot, and each holds its own copy of Django and your code.

Celery picks its default concurrency from the CPU count of the server, not the container's limit. In our test the worker ran under a one-CPU limit on an 8-core machine and started 8 processes. Set it yourself:

  • --concurrency 2 to 4 for tasks that mostly wait on email, HTTP APIs or the database.
  • --concurrency 1 for CPU-heavy tasks (images, PDFs) on one CPU. More processes only take turns on the same core.
  • --concurrency auto (new in Celery 5.7) sizes the pool from the container's CPU limit. It gave 1 under a one-CPU limit in our test.

CELERY_WORKER_MAX_MEMORY_PER_CHILD from the settings above replaces a process after a task leaves it over the limit, so a slow leak doesn't end in the container being killed. If it is killed anyway, see exit code 137.

Services count toward your monthly usage like any other app. Pro's quota is 1,000 GB-hours of memory and 150 CPU-hours a month across the account, measured from what each container actually uses, not from its limit. Past the quota, the extra comes out of your prepaid wallet.

Redis here is not durable

The Redis addon has no persistent volume and no backups. It has 128 MB of memory on every plan and no eviction policy set. Treat everything in it as data you can lose:

  • Queued tasks live in Redis until a worker takes them. If the Redis container is replaced, they're gone. For work that must happen (a payment, a receipt), write a row to Postgres first and have the task read it, so you can find and re-queue what didn't finish.
  • Results stored in Redis grow until they expire, after one day by default. That is why the settings above turn results off. If Redis goes past 128 MB, the container is killed and restarted.
  • Tasks with a countdown or ETA further away than an hour run more than once on a Redis broker, because Redis hands unacknowledged tasks out again after its one-hour visibility timeout. For work days ahead, store the due date in Postgres and let beat pick it up.

What happens on a push

Every push to the project's branch deploys the web service and every Celery service. To skip the worker when only templates or CSS changed, set watch paths on the service, for example shop/**, myproject/** and requirements.txt.

A worker deploy stops the old worker first. Docker sends it SIGTERM, and Celery's warm shutdown finishes the tasks it is running. Docker kills it 10 seconds later if it hasn't exited. With CELERY_TASK_ACKS_LATE, a task killed that way goes back on the queue and runs again once Redis's visibility timeout (one hour) passes. Split long tasks into short ones so a deploy rarely catches one.

The web and worker services deploy side by side, so a worker running new code can start before the web service has run that push's migrations. Add columns in one push and use them in the next, or make new tasks tolerate the old schema.

Celery on the Free plan

Services aren't on the Free plan, which has one project and one container. You can still start Celery in the web container, as the Django guide shows:

celery -A myproject worker --concurrency 1 & python manage.py migrate && gunicorn myproject.wsgi

Everything shares 256 MB, the app sleeps after 30 minutes without traffic, and the worker and beat stop with it. Tasks queued before it slept wait until a request wakes it, and periodic tasks due while it sleeps are skipped. Nothing restarts the worker if it crashes, since the container's main process is gunicorn. This is enough to try Celery; for a queue you rely on, Pro is $10 a month and runs each process in its own always-on container.

Deploy

  1. Sign in with GitHub and install the EthioDeploy app on the repo.
  2. Click “New Project” and pick the repo.
  3. Watch the build in the dashboard. When the health check passes, your app is live at <project-slug>.ethiodeploy.app. Every push to the default branch redeploys, and the old version keeps serving until the new one is healthy.

Troubleshooting

ModuleNotFoundError: No module named 'packaging' when the worker starts+

Cause: celery and redis were installed without the [redis] extra, which also installs packaging for kombu's Redis transport.

Fix: Replace them with celery[redis] in requirements.txt and redeploy.

The worker is killed (exit code 137) or restarts again and again+

Cause: Too many prefork processes for the container's memory. By default Celery starts one per CPU of the whole server.

Fix: Set --concurrency 2 (or auto) and CELERY_WORKER_MAX_MEMORY_PER_CHILD.

consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672//: [Errno 111] Connection refused.+

Cause: Celery didn't get a broker URL and fell back to its default, RabbitMQ on localhost.

Fix: Set CELERY_BROKER_URL = os.environ["REDIS_URL"] and check that the Redis addon is on the project.

Received unregistered task of type 'shop.tasks.…'+

Cause: The worker didn't import the module that defines the task.

Fix: Keep tasks in tasks.py inside an app listed in INSTALLED_APPS, and keep the celery_app import in myproject/__init__.py.

Periodic tasks run twice+

Cause: Two beat processes: a beat service plus -B on a worker, or -B on more than one worker.

Fix: Run beat in exactly one place.

A task with a countdown of several hours runs over and over+

Cause: Redis's one-hour visibility timeout re-delivers unacknowledged ETA tasks.

Fix: Store the due time in Postgres and let a beat task send it when it's due.

Still stuck? Check the deployment's build log in the dashboard, or see Troubleshooting.

Questions

Deploy the Django app as a web service, add a Redis addon for the broker and a Postgres addon for data, then add a Background worker service from the same repo with the start command celery -A myproject worker --concurrency 2. On EthioDeploy the worker service gets the project's env vars, including REDIS_URL. Services are on the Pro and Business plans.

In its own Background worker service with celery -A myproject beat, or inside a single worker with -B. Run exactly one beat, or every periodic task is sent twice.

As a broker, yes, with care. The Redis addon has no persistent volume and no backups, so queued tasks can be lost if the container is replaced. Keep important state in Postgres, make tasks safe to run twice, and don't store results in Redis.

It depends on your app's memory, since each prefork process holds a copy of Django. Start with --concurrency 2, watch the service's memory graph, and set CELERY_WORKER_MAX_MEMORY_PER_CHILD. Don't rely on the default: Celery counts the server's CPUs, not the container's one-CPU limit.

Only inside the web container, started in the background from the start command. The Free plan has 256 MB, no services, and the app sleeps after 30 minutes without traffic, which stops the worker and beat. Pro runs the worker in its own always-on container.

Ready to deploy?

Sign in with GitHub and pick your repo. No Dockerfile, no YAML.

More guides

FastAPIFlaskStreamlit

All guides on the deploy guides page. Custom domains, env vars, addons and billing are in the docs.

On this page
What runs whereAdd Celery to the Django projectCelery settingsAdd Redis and the worker serviceCelery beat for periodic tasksConcurrency and memoryRedis here is not durableWhat happens on a pushCelery on the Free planDeployTroubleshootingQuestions
Deploying with an agent?Point it at llms.txt. Every guide is in one file there.Open llms-full.txt →
EthioDeploy

Agentic first development and deployment, started in Ethiopia, built for developers everywhere.

Telegram community
Product
PricingAI coding agentAgent mode docsDomainsCLIFree backend hostingHosting in EthiopiaChangelog
Deploy guides
Next.jsNode.jsPythonSvelteKitTanStack StartAstroNuxtReact RouterHonoStrapiPayload CMSDjangoDjango + CeleryFastAPIFlaskStreamlitExpressNestJSSocket.IOLaravelRailsGoSpring BootASP.NET CoreTelegram botDiscord botWhatsApp botn8nLovableBoltReplitv0Google AI StudioBase44Firebase StudioClaude Code & Cursor
Compare
vs Herokuvs Vercelvs Rendervs Railwayvs Fly.iovs Netlifyvs KoyebHeroku alternativesVercel alternativesNetlify alternativesRender alternativesRailway alternativesFly.io alternativesReplit alternativesPythonAnywhere alternativesDigitalOcean App Platform alternativesGlitch alternatives
Resources
DocsBlogFree toolsAboutSupportContactllms.txt
© 2026 EthioDeployPay by card in USD or bank transfer in ETBTermsPrivacy