How to Deploy LibreChat on a VPS
Updated Aug 2026
verified on Ubuntu 26.04 · Aug 2026Self-host LibreChat on your own VPS — a feature-rich, multi-model ChatGPT alternative with plugins, presets, and support for OpenAI, Anthropic, and local models.
- 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
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 Hetzner CX22 (2 vCPU / 4 GB) works for remote-backend setups; combine with a CX42 (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.
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:
- Check the model dropdown — it should show models from your configured providers. If Ollama is connected, you'll see local models alongside cloud models.
- Send a test message — try a message with a cloud model (OpenAI/Anthropic) and a local model (Ollama). Both should work if configured correctly.
- 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:
- Disable open registration (Settings → Registration) once you've created all the accounts you need.
- Create user accounts (Admin Panel → Users) for each person who needs access.
- 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 Hetzner CX22 (2 vCPU / 4 GB) handles remote-backend setups; pair with a CX42 (8 vCPU / 16 GB) for local Ollama. See Best VPS for AI & ML Workloads for the ranked picks.