# Self-host Crawl4AI

> Web crawler that renders pages in a headless browser and returns clean markdown or structured data; the Docker server exposes it as a REST API with a playground, a monitoring dashboard and an MCP endpoint. Run your own Crawl4AI on an always-on EnvHaven workspace by asking its coding agent: one request installs it, puts it on an HTTPS address and locks it down. What the agent takes care of, and the manual route.

_Updated November 23, 2026_

Running your own Crawl4AI usually means a list of server chores: a machine that stays on, Docker or a runtime, a reverse proxy with certificates, a domain, and the settings that make Crawl4AI behave behind all of it. On an EnvHaven workspace you skip the list. You ask the coding agent, and it does the work while you watch.

## Just ask your agent

Open a Plus workspace (Crawl4AI runs in Docker, which Plus and Pro include), tap **Launch** to start any coding agent (Claude Code, Codex, OpenCode or another), and ask it:

```text
Set up Crawl4AI on this workspace and give me the link. Follow https://envhaven.com/self-host/crawl4ai.md
```

Then open the link it sends and create your Crawl4AI account straight away, before anyone else finds the address. That is the whole request: the address in it is this page's Markdown copy, and the agent follows the instructions for it further down, with every setting Crawl4AI's docs require.

## Or keep it private with Tailscale

The preview URL puts Crawl4AI on the public internet, which suits something other people need to reach. For an app only you and your household use, your tailnet is the better home: Tailscale gives Crawl4AI an HTTPS address that only your own devices, signed in to your Tailscale account, can open. Save a Tailscale auth key in the workspace's **Vars** pane as `TS_AUTHKEY`, and ask the agent:

```text
Set up Crawl4AI on my tailnet instead of the preview URL. Follow https://envhaven.com/self-host/crawl4ai.md and https://envhaven.com/guides/self-host-privately-with-tailscale.md
```

- A Tailscale container runs beside Crawl4AI, so it keeps its private address through workspace restarts and updates, and every app you set up this way gets an address of its own.
- Anything other services have to reach, such as a webhook, still needs a public address. [Keep self-hosted apps private with Tailscale](https://envhaven.com/guides/self-host-privately-with-tailscale) covers both, and what Tailscale's free plan includes.

| At a glance |  |
| --- | --- |
| What it is | AI chat, models and agent tools |
| License | Apache-2.0 |
| Runs as | Docker (`unclecode/crawl4ai`) |
| Memory | At least 4GB of RAM available for the container, more for heavy use ([docs](https://docs.crawl4ai.com/core/self-hosting/)) |
| Plan that fits | Plus or larger |
| Web port | 11235 |
| Documentation | [docs.crawl4ai.com/core/self-hosting/](https://docs.crawl4ai.com/core/self-hosting/) |

## What your agent takes care of

- **Installing it.** Crawl4AI runs from the official image, `unclecode/crawl4ai`, with its data in folders under `~/apps/crawl4ai`.
- **Putting it on an HTTPS address.** The workspace's preview URL serves it, and your own domain can too.
- **Locking it down first.** What Crawl4AI's docs say to set before it faces the internet, below.
- **Telling you what to back up**: Nothing is persistent by default: the compose file runs a read-only container with tmpfs mounts for /var/lib/redis, /var/lib/crawl4ai/outputs and /home/appuser/.crawl4ai, and Redis task data expires after one hour, .env with CRAWL4AI_API_TOKEN and .llm.env with LLM API keys and config.yml if you mount a customized copy ([docs](https://github.com/unclecode/crawl4ai/blob/main/deploy/docker/config.yml)).

### The settings it needs behind a proxy

- `CRAWL4AI_API_TOKEN`: With a token set the server may be exposed behind a TLS-terminating reverse proxy; every request except GET /health must send it as a Bearer token. ([docs](https://github.com/unclecode/crawl4ai/blob/main/deploy/docker/MIGRATION.md))
- `security.cors_allow_origins` in config.yml: Allowed browser origins for cross-origin calls; empty by default, which denies them. ([docs](https://github.com/unclecode/crawl4ai/blob/main/deploy/docker/MIGRATION.md))
- `security.trusted_hosts` in config.yml: Host allow list; the default is the wildcard ["*"], and the docs recommend specific hosts in production. ([docs](https://docs.crawl4ai.com/core/self-hosting/))
- WebSocket endpoints: The MCP endpoint /mcp/ws and the monitor endpoint /monitor/ws use WebSockets, so a proxy in front must pass upgrades; clients that cannot set headers may pass ?token=. ([docs](https://docs.crawl4ai.com/core/self-hosting/))

### Before it faces the internet

- Set CRAWL4AI_API_TOKEN (openssl rand -hex 32) and pass it with its value; the server refuses to bind a non-loopback address without a credential. ([docs](https://github.com/unclecode/crawl4ai/blob/main/deploy/docker/MIGRATION.md))
- Leave CRAWL4AI_HOOKS_ENABLED off unless hooks are needed, because they carry a remote code execution risk; for production the config comments also call for jwt_enabled and a random SECRET_KEY. ([docs](https://github.com/unclecode/crawl4ai/blob/main/deploy/docker/config.yml))
- Keep LLM API keys in .llm.env and out of version control. ([docs](https://docs.crawl4ai.com/core/self-hosting/))

## Things to ask next

Everything after the install is one more sentence to the agent. Some that come up:

- "Connect it to the API keys in my Vars pane, and make Claude the default model."
- "Add a second user account for my partner, without admin rights."
- "Move Crawl4AI to app.example.com." Add the domain on the dashboard's Domains page with a CNAME to `domains.envhaven.app`, and the agent changes Crawl4AI's address settings to match.
- "Update Crawl4AI to the latest release." It pulls the new image and recreates the container, data kept.

## Instructions for the agent

The agent reads these from the page's Markdown copy. They also work pasted on their own, if you would rather give them in your own words.

```text
Set up Crawl4AI on this workspace and serve it at my preview URL.
- Use Docker Compose with the official image, unclecode/crawl4ai, starting from the docs' compose file: https://github.com/unclecode/crawl4ai/blob/main/docker-compose.yml. If `docker compose` is missing, install the Compose plugin into ~/.docker/cli-plugins first.
- Keep the compose file in ~/apps/crawl4ai and all of its data in folders there (bind mounts, not named volumes), with restart: unless-stopped on every service.
- This server has no firewall, so publish no port on its public IP, and drop host networking and privileged mode from the docs' compose file. Docker runs on the host: connect this workspace to the compose network and relay my preview URL's port to Crawl4AI's port 11235.
- The preview URL terminates HTTPS in front of Crawl4AI: serve plain HTTP on its port, and trust the forwarded headers the relay passes on.
- Set what "The settings it needs behind a proxy" lists on https://envhaven.com/self-host/crawl4ai.md for the preview URL, as Crawl4AI's docs describe for running behind a proxy; skip any that apply only when Crawl4AI serves HTTPS itself.
- Before the preview URL serves it, apply what "Before it faces the internet" lists on https://envhaven.com/self-host/crawl4ai.md.
- When it answers at the preview URL, send me the link and tell me what to back up.
- If I asked for my tailnet instead of the preview URL, set Crawl4AI up the same way but follow https://envhaven.com/guides/self-host-privately-with-tailscale.md for the network: no preview URL, no relay.
```

## What to know

- In Docker, Crawl4AI's containers keep running when the workspace restarts or updates. The relay from the preview URL is a process in the workspace, so after a restart or an update, ask the agent to restore it.
- Request bodies are capped at 10 MiB by default (413 when exceeded), below Cloudflare's 100 MB request limit; the cap is limits.max_body_bytes in config.yml. ([docs](https://github.com/unclecode/crawl4ai/blob/main/deploy/docker/config.yml))
- Without a token the server listens only on the container's loopback, so published ports answer with connection reset even though the container reports healthy; every quickstart sets a token first. ([docs](https://github.com/unclecode/crawl4ai/blob/main/deploy/docker/README.md))
- The documented docker run and compose file set a 1 GB shared memory size (shm-size) for the container. ([docs](https://docs.crawl4ai.com/core/self-hosting/))
- No GPU is needed; GPU support is an optional build argument that defaults to false. ([docs](https://docs.crawl4ai.com/core/self-hosting/))
- Request rate limiting is on by default with in-memory storage, and the config comment says to use Redis for production. ([docs](https://github.com/unclecode/crawl4ai/blob/main/deploy/docker/config.yml))
- A workspace has one preview URL and one custom domain, both serving the same port, so it puts one app on a public address at a time.

## Without a workspace

The manual route, on a server you run:

1. Rent a Linux VPS, secure SSH, and create a user for the app.
2. Install Docker and write a compose file from the official image.
3. Put a reverse proxy in front (Caddy, nginx or Traefik), get certificates, and point a domain at the server.
4. Set the proxy settings listed above for that domain, and pass WebSocket upgrades through the proxy if the app uses them.
5. Keep the firewall closed except for the proxy, and schedule backups and updates.

Crawl4AI's own [documentation](https://docs.crawl4ai.com/core/self-hosting/) covers each step for its install methods.

## Sources

Facts about Crawl4AI come from its own documentation, checked on 2026-11-23:

- [docs.crawl4ai.com/core/self-hosting](https://docs.crawl4ai.com/core/self-hosting/)
- [github.com/unclecode/crawl4ai/blob/main/deploy/docker/MIGRATION.md](https://github.com/unclecode/crawl4ai/blob/main/deploy/docker/MIGRATION.md)
- [github.com/unclecode/crawl4ai/blob/main/deploy/docker/config.yml](https://github.com/unclecode/crawl4ai/blob/main/deploy/docker/config.yml)
- [github.com/unclecode/crawl4ai/blob/main/deploy/docker/README.md](https://github.com/unclecode/crawl4ai/blob/main/deploy/docker/README.md)

## Keep reading

- [Self-host any app with your agent](https://envhaven.com/self-host)
- [Self-host Open WebUI](https://envhaven.com/self-host/open-webui)
- [Self-host LibreChat](https://envhaven.com/self-host/librechat)
- [Self-host AnythingLLM](https://envhaven.com/self-host/anythingllm)
- [Self-host Dify](https://envhaven.com/self-host/dify)
- [AI agent hosting](https://envhaven.com/guides/ai-agent-hosting)

Source: https://envhaven.com/self-host/crawl4ai
