Install Open WebUI: Self-Hosted AI Chat on Your VPS
Open WebUI is an open-source, ChatGPT-style web interface that runs entirely on your own server. It connects to Ollama and any OpenAI-compatible API, letting you run Llama 3, Mistral, Gemma, Phi, and hundreds of other models without sending your data to third-party servers.
I've been running Open WebUI on a VPS for several months — shared team access, persistent chat history, file uploads, RAG support, and most importantly, every prompt stays on our own infrastructure.
Prerequisites
- VPS running Ubuntu 22.04/24.04 or Debian 12 (at least 4 GB RAM for Ollama + Open WebUI)
- Docker and Docker Compose installed
- Ollama running on the host (or an OpenAI API key as an alternative)
- A domain + SSL certificate if exposing to the internet (use Nginx reverse proxy)
Step 1 — Install Ollama (if not already installed)
Open WebUI needs an LLM backend. If you don't have Ollama yet, install it first:
# Install Ollama
curl -fsSL https://ollama.com/install.sh | sh
# Verify it's running
systemctl status ollama
# Pull a model (choose based on available RAM)
ollama pull llama3.2:3b # ~3 GB RAM
ollama pull mistral:7b # ~5 GB RAM
ollama pull gemma2:9b # ~7 GB RAM
Step 2 — Install Open WebUI with Docker Compose
Docker Compose is the easiest way to manage the container and its data volume:
# Create the directory
mkdir -p /opt/open-webui && cd /opt/open-webui
# Create docker-compose.yml
cat > docker-compose.yml << 'EOF'
version: '3.8'
services:
open-webui:
image: ghcr.io/open-webui/open-webui:main
container_name: open-webui
restart: unless-stopped
ports:
- "3000:8080"
volumes:
- open-webui-data:/app/backend/data
environment:
- OLLAMA_BASE_URL=http://host.docker.internal:11434
- WEBUI_SECRET_KEY=your-secret-key-change-this
extra_hosts:
- "host.docker.internal:host-gateway"
volumes:
open-webui-data:
EOF
# Replace the placeholder secret key
sed -i "s/your-secret-key-change-this/$(openssl rand -hex 32)/" docker-compose.yml
# Start the container
docker compose up -d
host.docker.internal:host-gateway entry allows the container to reach Ollama running on the host. On Linux Docker, this extra_hosts config is required — Docker Desktop on Mac/Windows handles it automatically.Step 3 — Configure Nginx Reverse Proxy with SSL
To serve Open WebUI over a domain with HTTPS, create an Nginx config:
# Create the Nginx config
cat > /etc/nginx/sites-available/open-webui << 'EOF'
server {
listen 80;
server_name chat.yourdomain.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name chat.yourdomain.com;
ssl_certificate /etc/letsencrypt/live/chat.yourdomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/chat.yourdomain.com/privkey.pem;
client_max_body_size 50M;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
}
}
EOF
# Enable the site
ln -s /etc/nginx/sites-available/open-webui /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx
proxy_read_timeout 300s is important — LLM responses for large models can take 2–5 minutes. Without this, Nginx will cut the connection midway through generation.Step 4 — Issue an SSL Certificate
# Issue the certificate with Certbot
certbot --nginx -d chat.yourdomain.com
# Verify auto-renewal is active
systemctl status certbot.timer
Step 5 — Create the First Admin Account
Open https://chat.yourdomain.com in your browser and register the first account — it automatically becomes the admin. Afterward, you can add more users or disable open registration from Settings > Admin Panel.
Recommended Settings
| Setting | Recommended Value | Reason |
|---|---|---|
| Default Model | Your pulled model | New users see this model first |
| Sign Up Enabled | Disabled (after setup) | Prevents outsiders from registering |
| RAG Embedding | nomic-embed-text | Enables PDF/TXT files as context |
| Image Generation | AUTOMATIC1111 or ComfyUI | Generate images directly in chat |
| Web Search | SearXNG (self-hosted) | Web search without leaking queries |
Connect to OpenAI API (Optional)
To use GPT-4o or Claude API alongside Ollama, add these environment variables to your docker-compose.yml:
# Under the environment: section in docker-compose.yml:
- OPENAI_API_KEY=sk-xxxxxxxxxxxx
- OPENAI_API_BASE_URL=https://api.openai.com/v1
# For OpenAI-compatible providers (Groq, Together.ai, etc.)
- OPENAI_API_BASE_URL=https://api.groq.com/openai/v1
Updating Open WebUI
cd /opt/open-webui
# Pull the latest image
docker compose pull
# Restart with the new image
docker compose up -d
# Verify the new version
docker compose exec open-webui cat /app/backend/version.txt
Verify Open WebUI Is Working Correctly
# Check the container is running
docker ps | grep open-webui
# Tail the logs
docker compose -f /opt/open-webui/docker-compose.yml logs --tail=50
# Test port 3000 is responding
curl -s -o /dev/null -w "%{http_code}" http://localhost:3000/
# Verify Ollama is reachable
curl -s http://localhost:11434/api/tags | python3 -m json.tool | grep name
# Confirm the data volume is intact
docker volume inspect open-webui-data | grep Mountpoint
curl localhost:3000 returns HTTP 200 but the page is blank, wait 30–60 seconds after the container starts — Open WebUI initializes its database on the first run.Common Errors and Fixes
Error: "Could not connect to Ollama"
The container can't find Ollama on the host. The most common cause is a missing extra_hosts entry or Ollama only listening on 127.0.0.1 instead of 0.0.0.0.
# Test connectivity from inside the container
docker exec open-webui curl -s http://host.docker.internal:11434/api/tags
# Check docker-compose.yml has extra_hosts
grep -A2 "extra_hosts" /opt/open-webui/docker-compose.yml
# Check what address Ollama is listening on
ss -tlnp | grep 11434
# Fix: make Ollama listen on all interfaces
sudo mkdir -p /etc/systemd/system/ollama.service.d
echo -e "[Service]\nEnvironment=\"OLLAMA_HOST=0.0.0.0\"" | \
sudo tee /etc/systemd/system/ollama.service.d/override.conf
sudo systemctl daemon-reload && sudo systemctl restart ollama
Error: "502 Bad Gateway" from Nginx
Nginx forwarded the request to port 3000 but the container isn't ready, or the LLM response timed out before Nginx's read timeout.
# Check whether the container is running
docker ps | grep open-webui
# Restart it if it's down
docker compose -f /opt/open-webui/docker-compose.yml up -d
# Check Nginx error log
tail -20 /var/log/nginx/error.log
# Increase the timeout if generation cuts out
# Set proxy_read_timeout 600s; in the location block
nginx -t && systemctl reload nginx
Error: "Disk quota exceeded" or container won't start
Chat history and uploaded files accumulate in the Docker volume over time. Check disk usage and prune unused Docker objects.
# Check volume size
docker system df -v | grep open-webui
# Check overall Docker disk usage
df -h /var/lib/docker
# Prune unused Docker cache (safe — won't touch data volumes)
docker system prune -f
# To remove old conversations, use Admin Panel > Database
Error: "CSRF validation failed" behind Nginx proxy
Open WebUI didn't receive the X-Forwarded-Proto header, so it thinks the request came in over HTTP instead of HTTPS.
# Confirm Nginx is sending the required headers
grep -A15 "location /" /etc/nginx/sites-available/open-webui
# Must include:
# proxy_set_header X-Forwarded-Proto $scheme;
# proxy_set_header Host $host;
# Also set WEBUI_URL in docker-compose.yml
# Under environment:
# - WEBUI_URL=https://chat.yourdomain.com
docker compose up -d
Models load extremely slowly or generation hangs
Ollama loads the model into RAM on first use, which can take 30–120 seconds. If it takes much longer, your VPS is likely hitting its memory limit and swapping heavily.
# Watch Ollama logs while loading
sudo journalctl -u ollama -f
# Check available RAM
free -h
# List currently loaded models
curl -s http://localhost:11434/api/ps | python3 -m json.tool
# If swap is thrashing, switch to a smaller model
ollama rm mistral:7b
ollama pull llama3.2:3b
Frequently Asked Questions
What's the difference between Open WebUI and Ollama Web UI?
Ollama Web UI was the project's original name before it was rebranded as Open WebUI in 2024. They are the same project — every feature is identical. Open WebUI is the current, correct name. The old name still appears in outdated tutorials, which causes confusion.
Do I need Ollama? Can I use the OpenAI API exclusively?
Open WebUI works perfectly fine without Ollama. Just set OPENAI_API_KEY and OPENAI_API_BASE_URL in the environment variables and you can use GPT-4o, Claude Sonnet, Groq, or any OpenAI-compatible endpoint immediately. The advantage of pairing it with Ollama is that most queries run locally with no API cost.
Where is chat history stored? Is it private?
All conversations are stored in a SQLite database inside the open-webui-data Docker volume on your VPS only. Nothing is sent externally — except when you use an OpenAI/Claude API connection, in which case prompts are forwarded to that provider as normal. To back up the data, run: docker run --rm -v open-webui-data:/data -v /backup:/backup alpine tar czf /backup/open-webui-$(date +%Y%m%d).tar.gz /data