Skip to content

How to Deploy LibreChat on a VPS

Updated Sep 2026

verified on Ubuntu 26.04 · Aug 2026
We earn commissions when you shop through the links below. Full disclosure →

Self-host LibreChat on your own VPS — a feature-rich, multi-model ChatGPT alternative with plugins, presets, and support for OpenAI, Anthropic, and local models.

Before you start
  • A VPS with 4+ GB RAM (8 GB recommended with local models)
  • A fresh Ubuntu 26.04 server with root/sudo SSH access
  • Optional: Ollama running on the same server or accessible remotely
Need a box for this guide? Kamatera's free tier lets you spin one up now.Start free on Kamatera → (opens in new tab)

What LibreChat is

LibreChat is an open-source, feature-rich alternative to ChatGPT's web interface. It supports multiple AI providers (OpenAI, Anthropic, Google, Ollama, and more) in a single interface, with conversation branching, plugins, presets, and multi-user support. Think of it as ChatGPT with the ability to mix and match models from different providers in the same conversation.

The appeal is multi-model flexibility. Instead of being locked into one provider, you can start a conversation with Claude, switch to GPT-4 for a different task, and finish with a local Ollama model — all in the same chat. LibreChat also supports custom endpoints, so you can connect to any OpenAI-compatible API.

For teams, LibreChat adds user management, conversation sharing, and role-based access. It's the self-hosted alternative to tools like ChatGPT Plus or Claude Pro, but with the ability to use your own API keys and run local models alongside cloud providers.

Server sizing — the UI is light, the backends are not

LibreChat's backend is a Node.js application with MongoDB for storage. It's not compute-intensive — the heavy lifting is model inference, which happens in the backends (OpenAI, Anthropic, Ollama, etc.).

LibreChat alone (with remote backends):

  • 2 GB RAM — handles the web UI, user management, and API calls
  • 4 GB RAM — comfortable for multiple concurrent users and conversation history

With Ollama on the same box: Add the Ollama sizing requirements. A 7B model needs ~8 GB for Ollama, so plan for 12-16 GB total.

MongoDB considerations: LibreChat uses MongoDB to store conversations, users, and settings. The database is lightweight for a small team — 1-2 GB RAM is enough. For larger deployments, consider a separate MongoDB instance.

The practical minimum is 4 GB RAM if you're using remote backends only, and 16 GB RAM if you're running Ollama locally with a 7B model. A 2 vCPU / 4 GB VPS works for remote-backend setups; step up to 8 vCPU / 16 GB for local Ollama.

Prepare the server

Start from a fresh Ubuntu 24.04 or 26.04 server. Update and create a non-root user:

apt update && apt upgrade -y
adduser deploy
usermod -aG sudo deploy

Lock down the firewall:

ufw allow OpenSSH
ufw allow 80
ufw allow 443
ufw enable

Install Docker:

curl -fsSL https://get.docker.com | sh
usermod -aG docker deploy

Log out and back in as deploy so the docker group takes effect.

Where to host itaffiliate disclosure
Hetzner Cloudrun it on
2 vCPU · 4 GB RAM · 80 GB SSD · $23.59/mo
Get Hetzner Cloud (opens in new tab)
Kamaterafree trial
1 vCPU · 1 GB RAM · 20 GB SSD · $4.00/mo
Start free on Kamatera → (opens in new tab)
DigitalOceanalso works on
1 vCPU · 1 GB RAM · 25 GB SSD · $6.00/mo
Deploy on DigitalOcean → (opens in new tab)

Paid link — we earn a commission if you shop through it.

Install LibreChat

Create a working directory:

mkdir ~/librechat && cd ~/librechat

Create a .env file with your configuration:

cat > .env <<EOF
# Domain and security
ALLOW_REGISTRATION=true
ALLOW_SOCIAL_LOGIN=false
ALLOW_SOCIAL_REGISTRATION=false
APP_TITLE=My AI Chat
HOST_DOMAIN=ai.example.com
HOST_PORT=443

# MongoDB
MONGO_URI=mongodb://mongo:27017/LibreChat

# Session
CREDS_KEY=$(openssl rand -hex 32)
CREDS_IV=$(openssl rand -hex 16)
JWT_SECRET=$(openssl rand -hex 32)
JWT_REFRESH_SECRET=$(openssl rand -hex 32)

# API keys (add your own)
OPENAI_API_KEY=
ANTHROPIC_API_KEY=

# Ollama (if using)
OLLAMA_BASE_URL=http://host.docker.internal:11434
EOF

Create a compose file:

services:
  librechat:
    image: ghcr.io/danny-avila/librechat:latest
    restart: unless-stopped
    ports:
      - "127.0.0.1:3080:3080"
    depends_on:
      - mongo
    env_file:
      - .env
    volumes:
      - ./images:/app/client/public/images
      - ./librechat_data:/app/backend/data
    extra_hosts:
      - "host.docker.internal:host-gateway"

  mongo:
    image: mongo:6
    restart: unless-stopped
    ports:
      - "127.0.0.1:27017:27017"
    volumes:
      - mongo_data:/data/db

volumes:
  mongo_data:
  librechat_data:

Start it:

docker compose up -d

LibreChat listens on port 3080. The 127.0.0.1 bind keeps it private.

Configure model providers

LibreChat supports multiple providers. Configure them in the .env file:

OpenAI:

OPENAI_API_KEY=sk-your-key-here

Anthropic:

ANTHROPIC_API_KEY=sk-ant-your-key-here

Ollama:

OLLAMA_BASE_URL=http://host.docker.internal:11434

Google Gemini:

GOOGLE_API_KEY=your-key-here

After changing the .env file, restart LibreChat:

docker compose up -d

HTTPS + domain

LibreChat needs HTTPS for production use. Point a reverse proxy at 127.0.0.1:3080 and terminate HTTPS on 443.

The simplest path is Automatic HTTPS with Caddy. Point an A record for your hostname (say ai.example.com) at the server's public IP, then have Caddy reverse-proxy that hostname to 127.0.0.1:3080.

If you're using the Caddy container approach, put LibreChat and Caddy in the same compose file and proxy to the LibreChat service name:

reverse_proxy librechat:3080

First-run setup

Load https://ai.example.com in your browser. On a fresh install, LibreChat shows an admin setup screen.

Create the admin account immediately. The setup screen is open until the first account exists — whoever registers first becomes the admin. Set your email and a strong password.

Once you're in:

  1. Check the model dropdown — it should show models from your configured providers. If Ollama is connected, you'll see local models alongside cloud models.
  2. Send a test message — try a message with a cloud model (OpenAI/Anthropic) and a local model (Ollama). Both should work if configured correctly.
  3. Explore presets — LibreChat lets you save model configurations as presets. Create a "Local Only" preset that uses only Ollama, and a "Cloud Only" preset for API models.

Multi-user setup

LibreChat supports multiple users with role-based access. After creating the admin account:

  1. Disable open registration (Settings → Registration) once you've created all the accounts you need.
  2. Create user accounts (Admin Panel → Users) for each person who needs access.
  3. Set default models (Settings → General) to control which model new conversations start with.

Users get their own conversation history and settings, but they all share the same API keys and model backends. There's no per-user API key isolation — everyone uses the same keys.

Backups

LibreChat stores conversations in MongoDB and settings in the data volume. Back up both:

# Backup MongoDB
docker compose exec -T mongo mongodump --archive | gzip > librechat-mongo-$(date +%F).sql.gz

# Backup LibreChat data
docker run --rm -v librechat_data:/data -v $(pwd):/backup alpine \
  tar czf /backup/librechat-data-$(date +%F).tar.gz -C /data .

Restore MongoDB from a dump:

gunzip -c librechat-mongo-2026-08-08.sql.gz | docker compose exec -T mongo mongorestore --archive

Upgrades

Pull the newer image and recreate:

docker compose pull
docker compose up -d

LibreChat runs database migrations automatically. Check the LibreChat changelog for breaking changes before a major version bump.

Troubleshooting

Can't connect to Ollama. Verify Ollama is running (docker compose ps in the Ollama directory) and the URL is correct. If both are on the same server, http://host.docker.internal:11434 should work.

API key errors. Check that your API keys are valid and have credits. For OpenAI, verify the key at platform.openai.com. For Anthropic, check console.anthropic.com.

MongoDB connection errors. Verify MongoDB is running (docker compose ps) and the MONGO_URI is correct. Check MongoDB logs for authentication errors.

"Unauthorized" errors. Your JWT secrets may have changed. If you regenerated them, you'll need to log in again with the admin credentials.

Slow responses from Ollama. Expected without a GPU. CPU inference is 5-10x slower than GPU. Consider using a smaller model or adding a GPU.

Conversations missing after restart. LibreChat stores data in Docker volumes. If volumes were removed or recreated, conversations are lost. Back up the data volumes regularly.

Verification + next steps

You're done when you can: load the web interface over HTTPS, sign in as admin, switch between different model providers, send messages and get responses, and create additional user accounts. The model dropdown should show available models from all configured providers.

From here, explore LibreChat's advanced features like conversation branching, custom endpoints, and plugin support. For a simpler multi-model interface, see Open WebUI. For document-based AI workflows, see AnythingLLM. A 2 vCPU / 4 GB box handles remote-backend setups; step up to 8 vCPU / 16 GB for local Ollama. See Best VPS for AI & ML Workloads for the ranked picks.

Next steps

How to self-host LibreChat →More self-hosted ai chat interfaces tools →Best VPS for AI & LLM Apps →Automatic HTTPS with Caddy →Run Claude Code with Ollama on Your Own VPS →Deploy Coolify on a VPS →How to Deploy Actual Budget on a VPS →How to Deploy AnythingLLM on a VPS →How to Deploy Appwrite on a VPS →How to Deploy Audiobookshelf on a VPS →How to Deploy Authelia on a VPS →How to Deploy authentik on a VPS →How to Deploy Baserow on a VPS →How to Deploy Beszel on a VPS →How to Deploy Bitwarden on a VPS →How to Deploy BookStack on a VPS →How to Deploy CapRover on a VPS →How to Deploy Checkmate on a VPS →How to Deploy Directus on a VPS →How to Deploy docker-mailserver on a VPS →How to Deploy Docmost on a VPS →How to Deploy Dokku on a VPS →How to Deploy Dokploy on a VPS →How to Deploy Firefly III on a VPS →How to Deploy Forgejo on a VPS →How to Deploy Gatus on a VPS →How to Deploy Ghostfolio on a VPS →How to Deploy Gitea on a VPS →How to Deploy GitLab on a VPS →How to Deploy GlitchTip on a VPS →How to Deploy Grafana on a VPS →How to Deploy Graylog on a VPS →How to Deploy Headscale on a VPS →How to Deploy Healthchecks on a VPS →How to Deploy Home Assistant on a VPS →How to Deploy Immich on a VPS →How to Deploy Jan on a VPS →How to Deploy Jellyfin on a VPS →How to Deploy Karakeep on a VPS →How to Deploy Keycloak on a VPS →How to Deploy Leantime on a VPS →How to Deploy Linkwarden on a VPS →How to Deploy LocalAI on a VPS →How to Deploy Mailcow on a VPS →How to Deploy Mailu on a VPS →How to Deploy Matomo on a VPS →How to Deploy Mattermost on a VPS →How to Deploy Meilisearch on a VPS →How to Deploy Memos on a VPS →How to Deploy n8n on a VPS →How to Deploy Navidrome on a VPS →How to Deploy NetBird on a VPS →How to Deploy Netdata on a VPS →How to Deploy Nextcloud on a VPS →How to Deploy Next.js to a VPS →How to Deploy Nginx Proxy Manager on a VPS →How to Deploy NocoDB on a VPS →How to Deploy ntfy on a VPS →How to Deploy Ollama on a VPS →How to Deploy Open WebUI on a VPS →How to Deploy OpenHands on a VPS →How to Deploy OpenObserve on a VPS →How to Deploy OpenProject on a VPS →How to Deploy Outline on a VPS →How to Deploy Pangolin on a VPS →How to Deploy Paperless-ngx on a VPS →How to Deploy Passbolt on a VPS →How to Deploy Plane on a VPS →How to Deploy Plausible Analytics on a VPS →How to Deploy Pocket ID on a VPS →How to Deploy PocketBase on a VPS →How to Deploy Prometheus on a VPS →How to Deploy Psono on a VPS →How to Deploy Radarr on a VPS →How to Deploy Rocket.Chat on a VPS →How to Deploy SigNoz on a VPS →How to Deploy Sonarr on a VPS →How to Deploy Stalwart on a VPS →How to Deploy Stirling-PDF on a VPS →How to Deploy Supabase on a VPS →How to Deploy Synapse on a VPS →How to Deploy Taiga on a VPS →How to Deploy TeamPass on a VPS →How to Deploy Tinyauth on a VPS →How to Deploy Traefik on a VPS →How to Deploy Trilium on a VPS →How to Deploy Twenty CRM on a VPS →How to Deploy Umami on a VPS →How to Deploy Uptime Kuma on a VPS →How to Deploy Vaultwarden on a VPS →How to Deploy Vikunja on a VPS →How to Deploy wg-easy on a VPS →How to Deploy Wiki.js on a VPS →How to Deploy Zabbix on a VPS →How to Deploy Zitadel on a VPS →How to Deploy Zulip on a VPS →Docker & Compose on Ubuntu 26.04 →Building AI Workflows with n8n →Install Open WebUI with Ollama →Adding AI-Powered Insights to Plausible Analytics →Building AI-Powered Apps with Supabase and pgvector →

We use analytics cookies (Google Analytics, PostHog) to see which guides are useful. No ad networks, no cross-site tracking. See our privacy policy.