Skip to content
Back to skills

Uvicorn

ASecurity

Uvicorn is a lightning-fast ASGI server for Python. It's the recommended way to run FastAPI, Starlette, and Django ASGI in production. For multi-core utilization, pair it with Gunicorn as a process manager.

  • 65 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added May 30, 2026
developmentpythonrustgobashfastapidjangodockerapi

Works with

  • cli
  • api

Security analysis

A96/100
  • mediumInstalls packages at runtime which could introduce malicious dependencies

Pro shows the line behind each finding and how to fix it

Scanned May 30, 2026

npx -y skills add ComeOnOliver/skillshub --skill uvicorn --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Uvicorn?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Uvicorn
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/comeonoliver-uvicorn/badge)](https://www.skillsdirectory.com/skills/comeonoliver-uvicorn)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# Uvicorn

## Overview

Uvicorn is a lightning-fast ASGI server for Python. It's the recommended way to run FastAPI, Starlette, and Django ASGI in production. For multi-core utilization, pair it with Gunicorn as a process manager.

## Instructions

### Step 1: Development

```bash
pip install uvicorn[standard]

# Run with auto-reload
uvicorn app.main:app --reload --port 8000
```

### Step 2: Production with Gunicorn

```bash
pip install gunicorn

# Gunicorn manages multiple Uvicorn worker processes
gunicorn app.main:app \
  --workers 4 \                    # CPU cores × 2 + 1
  --worker-class uvicorn.workers.UvicornWorker \
  --bind 0.0.0.0:8000 \
  --timeout 120 \
  --graceful-timeout 30 \
  --access-logfile - \
  --error-logfile -
```

### Step 3: Docker Production

```dockerfile
FROM python:3.12-slim
WORKDIR /app

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

# Non-root user
RUN adduser --system --uid 1001 app
USER app

# Production command
CMD ["gunicorn", "app.main:app", \
     "--workers", "4", \
     "--worker-class", "uvicorn.workers.UvicornWorker", \
     "--bind", "0.0.0.0:8000", \
     "--timeout", "120"]
```

### Step 4: Programmatic Configuration

```python
# run.py — Uvicorn with programmatic config
import uvicorn

if __name__ == "__main__":
    uvicorn.run(
        "app.main:app",
        host="0.0.0.0",
        port=8000,
        workers=4,
        log_level="info",
        access_log=True,
        proxy_headers=True,        # trust X-Forwarded-* from reverse proxy
        forwarded_allow_ips="*",
    )
```

## Guidelines

- Development: `uvicorn --reload` (single process, auto-reload on file changes).
- Production: `gunicorn` with `UvicornWorker` class (multi-process, no reload).
- Workers formula: `(2 × CPU cores) + 1` — e.g., 4 cores → 9 workers.
- Always use behind a reverse proxy (nginx, Caddy) for TLS termination and static files.
- Set `proxy_headers=True` when behind a load balancer to get real client IPs.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.