# How to use Celery with LavinMQ

By Lovisa Johansson. Published 22 September 2026.

LavinMQ is the message broker for your Celery tasks. Celery handles creating and executing tasks, while LavinMQ sits between your application and Celery workers, storing task messages and delivering them to workers when they are ready. It speaks AMQP natively, uses little memory, and needs nothing more than a connection string to get started.

[Celery](https://docs.celeryq.dev/en/stable/) is a Python library for running tasks in the background instead of blocking your main application. It needs a message broker to move tasks between clients and workers, and LavinMQ handles that job.

Teams use Celery with LavinMQ for things like sending order confirmations without blocking checkout, encoding video after upload, generating reports in the background, or running scheduled jobs like shipment tracking updates.

Python’s py-amqp, the library Celery runs on, shows up on about 13% of CloudAMQP clusters. That number includes anyone using py-amqp directly, not just Celery users, so it’s a rough signal rather than an exact Celery count.

## Step 1: Install Celery

```bash
pip install celery
```

## Step 2: Create a LavinMQ instance

Sign up for a [CloudAMQP account](https://www.cloudamqp.com) and create a new LavinMQ instance. The free plan works fine for testing.

Once the instance is up, open its details page and copy the AMQP connection URL. It looks like this:

```bash
amqps://user:password@host/vhost
```

## Step 3: Point Celery at LavinMQ

Set [`broker_url`](https://docs.celeryq.dev/en/stable/userguide/configuration.html#broker-url) to your LavinMQ connection string. Save this as `tasks.py`:

```python
from celery import Celery

app = Celery('tasks', broker='amqps://user:password@host/vhost')

@app.task
def add(x, y):
    return x + y
```

Celery talks to LavinMQ over standard AMQP, so no extra transport or driver is needed.

## Step 4: Start a worker and send a task

```bash
celery -A tasks worker --loglevel=info
```

From another shell or script, send a task:

```python
from tasks import add

result = add.delay(4, 6)
print(result.get())
```

The worker picks up the task from LavinMQ and returns the result.

## Summary

LavinMQ is a solid default for Celery: fast to set up, low on resource use, and built on the AMQP protocol Celery already speaks.

Already running Celery on another broker? Moving to LavinMQ is usually just a matter of updating the `broker_url`.

[Create a free LavinMQ instance](https://customer.cloudamqp.com/instance/create?plan=lemming&topic=selected_plan) and try it with your own Celery tasks.
