# Self-host LibreChat

> Self-hosted multi-user chat web app that sends requests to the AI providers and endpoints you configure. Run your own LibreChat 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 LibreChat 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 LibreChat 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 (LibreChat 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 LibreChat on this workspace and give me the link. Follow https://envhaven.com/self-host/librechat.md
```

Then open the link it sends and create your LibreChat 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 LibreChat's docs require.

## Or keep it private with Tailscale

The preview URL puts LibreChat 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 LibreChat 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 LibreChat on my tailnet instead of the preview URL. Follow https://envhaven.com/self-host/librechat.md and https://envhaven.com/guides/self-host-privately-with-tailscale.md
```

- A Tailscale container runs beside LibreChat, 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 | MIT |
| Runs as | Docker (`registry.librechat.ai/librechat-ai/librechat-api:latest`) |
| Memory | 1 GiB minimum; at least 2 GB available to Docker with everything running ([docs](https://www.librechat.ai/docs/local/docker)) |
| Plan that fits | Plus or larger |
| Web port | 3080 |
| Documentation | [www.librechat.ai/docs/remote/docker_linux](https://www.librechat.ai/docs/remote/docker_linux) |

## What your agent takes care of

- **Installing it.** LibreChat runs from the official image, `registry.librechat.ai/librechat-ai/librechat-api:latest`, with its data in folders under `~/apps/librechat`.
- **Putting it on an HTTPS address.** The workspace's preview URL serves it, and your own domain can too.
- **Locking it down first.** What LibreChat's docs say to set before it faces the internet, below.
- **Telling you what to back up**: ./data-node (MongoDB data, mounted at /data/db), ./meili_data_v1.35.1 (Meilisearch index), ./uploads, ./images and ./logs, named volume pgdata2 (pgvector database for the RAG API), named volume librechat-data (/app/data, holds the generated .env.temp credentials) and .env and librechat.yaml ([docs](https://www.librechat.ai/docs/configuration/upgrade)).

### The settings it needs behind a proxy

- `DOMAIN_CLIENT` and `DOMAIN_SERVER`: Set both in .env to the public HTTPS URL (for example https://chat.example.com) and restart; they feed generated links, cookies and OAuth callbacks. ([docs](https://www.librechat.ai/docs/remote/cloudflare))
- `DOMAIN_CLIENT`: Address LibreChat puts in the links it generates; point it at the public URL, not at the address the browser happens to use. ([docs](https://www.librechat.ai/docs/quick_start/first_chat))
- `TRUST_PROXY`: Number of reverse-proxy hops Express trusts when reading X-Forwarded-For; default 1. ([docs](https://www.librechat.ai/docs/configuration/dotenv))
- `SESSION_COOKIE_SECURE`: Overrides the Secure attribute on session and auth cookies; when unset it is chosen from NODE_ENV and DOMAIN_SERVER. ([docs](https://www.librechat.ai/docs/configuration/dotenv))
- Upstream address for the tunnel or reverse proxy: Point the proxy at port 3080 with the default docker-compose.yml or npm, or at port 80 (the NGINX container) with deploy-compose.yml. ([docs](https://www.librechat.ai/docs/remote/cloudflare))

### Before it faces the internet

- In a single-tenant deployment the first account registered becomes the admin and there are no default credentials, so register it immediately after exposing the instance. ([docs](https://www.librechat.ai/docs/local/docker))
- After creating your own account, set ALLOW_REGISTRATION=false to close sign-ups. ([docs](https://www.librechat.ai/docs/remote/docker_linux))
- Use fixed, unique CREDS_KEY, CREDS_IV, JWT_SECRET and JWT_REFRESH_SECRET in production; blank values are generated into /app/data/.env.temp on first start. ([docs](https://www.librechat.ai/docs/configuration/dotenv))
- The bundled admin panel needs ADMIN_PANEL_SESSION_SECRET (at least 32 characters, from openssl rand -hex 32) before it starts. ([docs](https://www.librechat.ai/docs/configuration/dotenv))
- Without valid Mailgun or SMTP settings, password reset falls back to an unsecured flow. ([docs](https://www.librechat.ai/docs/configuration/dotenv))

## 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 LibreChat to app.example.com." Add the domain on the dashboard's Domains page with a CNAME to `domains.envhaven.app`, and the agent changes LibreChat's address settings to match.
- "Update LibreChat 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 LibreChat on this workspace and serve it at my preview URL.
- Use Docker Compose with the official image, registry.librechat.ai/librechat-ai/librechat-api:latest, starting from the docs' compose file: https://github.com/LibreChat-AI/LibreChat/blob/main/docker-compose.yml. If `docker compose` is missing, install the Compose plugin into ~/.docker/cli-plugins first.
- The docs' setup includes: mongodb; meilisearch (conversation search); rag_api (file search); vectordb (PostgreSQL with pgvector, used by rag_api); deploy-compose.yml only: nginx client container on ports 80 and 443.
- Keep the compose file in ~/apps/librechat 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 LibreChat's port 3080.
- The preview URL terminates HTTPS in front of LibreChat: 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/librechat.md for the preview URL, as LibreChat's docs describe for running behind a proxy; skip any that apply only when LibreChat serves HTTPS itself.
- Before the preview URL serves it, apply what "Before it faces the internet" lists on https://envhaven.com/self-host/librechat.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 LibreChat 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, LibreChat'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.
- The default MongoDB image crashes at startup on CPUs without AVX, including on some virtual machines that do not expose AVX to the guest; the docs give a mongo:4.4.18 override. ([docs](https://www.librechat.ai/docs/local/docker))
- No GPU is needed because model inference happens at the configured providers. ([docs](https://www.librechat.ai/docs/local/docker))
- Building the frontend from source needs far more memory than running it, so on a low-memory machine the docs say to use the prebuilt Docker images. ([docs](https://www.librechat.ai/docs/local/npm))
- Uploads are capped by fileConfig.serverFileSizeLimit in librechat.yaml (megabytes). Set it at or below 100 so the app enforces its own limit before Cloudflare's 100 MB request body limit applies. ([docs](https://www.librechat.ai/docs/configuration/librechat_yaml/object_structure/file_config))
- The default RAG API image only supports remote embeddings; local embeddings need the full RAG API image. ([docs](https://www.librechat.ai/docs/configuration/rag_api))
- Password reset and account verification email needs Mailgun or SMTP. Mailgun's API avoids outbound SMTP ports that some servers block. ([docs](https://www.librechat.ai/docs/configuration/dotenv))
- 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.

LibreChat's own [documentation](https://www.librechat.ai/docs/remote/docker_linux) covers each step for its install methods.

## Sources

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

- [librechat.ai/docs/remote/docker_linux](https://www.librechat.ai/docs/remote/docker_linux)
- [librechat.ai/docs/local/docker](https://www.librechat.ai/docs/local/docker)
- [librechat.ai/docs/remote/cloudflare](https://www.librechat.ai/docs/remote/cloudflare)
- [librechat.ai/docs/quick_start/first_chat](https://www.librechat.ai/docs/quick_start/first_chat)
- [librechat.ai/docs/configuration/dotenv](https://www.librechat.ai/docs/configuration/dotenv)
- [librechat.ai/docs/local/npm](https://www.librechat.ai/docs/local/npm)
- [librechat.ai/docs/configuration/librechat_yaml/object_structure/file_config](https://www.librechat.ai/docs/configuration/librechat_yaml/object_structure/file_config)
- [librechat.ai/docs/configuration/rag_api](https://www.librechat.ai/docs/configuration/rag_api)
- [librechat.ai/docs/configuration/upgrade](https://www.librechat.ai/docs/configuration/upgrade)

## 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 AnythingLLM](https://envhaven.com/self-host/anythingllm)
- [Self-host Dify](https://envhaven.com/self-host/dify)
- [Self-host Langflow](https://envhaven.com/self-host/langflow)
- [AI agent hosting](https://envhaven.com/guides/ai-agent-hosting)

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