How to Self Host Ollama and Open Webui on a Cheap VPS
Disclosure: Some links in this article are affiliate links. If you click and make a purchase, we may earn a commission at no extra cost to you. This does not influence our editorial recommendations - we only recommend products and services we genuinely believe in. Read our full affiliate disclosure.

Last month, I audited a mid-sized remote development agency that was burning $1,400 a month on commercial enterprise AI API keys. Every time a developer pasted a snippet of proprietary code into a browser-based chat window to debug a database query, their proprietary intellectual property left their secure perimeter. When I suggested they pull their workloads in-house, the default objection was the same old tired excuse: "Self-hosting requires an expensive, dedicated rack of enterprise GPUs in a data center."
They were wrong. And if you're still paying monthly seat fees for closed-source AI wrappers, you're lighting money on fire.
By pairing Ollama - the lightweight runtime for local large language models - with Open WebUI, a feature-rich, ChatGPT-style interface, you can spin up your own private, encrypted AI workspace on a budget VPS for less than the cost of a single specialty coffee per month.
At RemoGrid, we don't justηθ«ize; we test infrastructure under real workloads. I deployed this exact stack on a $12-a-month Hetzner cloud instance and ran our team's daily text summarization, code reviews, and document querying through it for thirty days. Here is the exact, unvarnished blueprint to build your own private AI infrastructure today.
RemoGrid is reader-supported. When you sign up or purchase through links on our site, we may earn an affiliate commission at no extra cost to you. We test every platform independently.
Why Self-Host Your AI Stack?
Before we touch a terminal, let's talk about the hard economics and operational security risks of relying on third-party cloud AI vendors.
When you use commercial chat interfaces:
- Data Privacy Is an Illusion: Unless you pay for enterprise tiers with strict zero-retention addendums, your prompts and uploaded documents are often used to train subsequent model iterations.
- Subscription Creep: What starts as a $20/month pro plan quickly scales into hundreds of dollars in user licensing fees as your team or freelance collective expands.
- Vendor Lock-in: API rate limits, sudden pricing hikes, and unexpected policy changes can break your automated workflows overnight.
Self-hosting Ollama and Open WebUI on a Virtual Private Server gives you absolute sovereignty. Your data never leaves your rented slice of server hardware. If you want to dive deeper into securing your remote workflow tools, check out our guide on setting up secure remote development environments.
Choosing the Right VPS Provider and Specs
Running large language models requires balancing three hardware constraints: RAM capacity, CPU core count/bandwidth, and disk throughput.
Because models must reside in system memory (RAM) during inference, your VPS RAM size dictates the maximum parameter size of the model you can load. A 7-parameter (7B) model typically requires at least 6GB to 8GB of RAM to run comfortably alongside the operating system and Docker runtime.
Let's look at how popular budget VPS providers stack up for this specific workload:
| Provider | Instance Type | vCPUs | RAM | NVMe Storage | Monthly Cost | Best For |
|---|---|---|---|---|---|---|
| Hetzner | CPX31 | 4 vCPU | 8 GB | 160 GB | ~$8.50 | Best overall value for CPU-bound 8B models |
| DigitalOcean | Basic Droplet | 2 vCPU | 4 GB | 80 GB | $24.00 | Good network reliability, but tight on RAM |
| Vultr | Cloud Compute | 4 vCPU | 16 GB | 320 GB | $40.00 | Heavy multi-model concurrency |
| RunPod | Community GPU | 2 vCPU | 15 GB | 50 GB + RTX 3090 | ~$72.00 | Blazing fast token generation with dedicated VRAM |
If you are just starting out with personal projects or a small remote team, a dedicated CPU instance with 8GB of RAM provides the sweet spot. You won't get 60 tokens per second, but 10 to 15 tokens per second is more than adequate for asynchronous tasks like drafting emails, writing boilerplate code, and parsing text.
Step 1: Provisioning Your VPS and Installing Docker
For this guide, we will use a fresh Ubuntu 24.04 LTS instance. Log into your VPS provider, deploy your instance, and SSH into the terminal as root or a user with sudo privileges:
Once logged in, update your package lists and install essential system utilities:
Next, install Docker and Docker Compose. We use Docker because it isolates the Ollama runtime and Open WebUI interface, preventing dependency conflicts with the host OS.
Verify that Docker is running correctly by executing:
Step 2: Configuring Docker Compose for Ollama and Open WebUI
Rather than running complex individual Docker run commands, we will manage our entire stack using a single docker-compose.yml file. This ensures that both containers can communicate over an internal Docker network and persist their data across system reboots.
Create a dedicated directory for your AI stack and navigate into it:
Now, create the docker-compose.yml file using your preferred text editor (like nano):
Paste the following configuration into the file:
Save and exit the file (in nano, press Ctrl+O, Enter, then Ctrl+X).

Step 3: Launching the Stack and Pulling Your First Model
With your configuration file saved, fire up the containers in detached mode using Docker Compose:
Docker will pull the latest Ollama runtime and Open WebUI images from their respective registries. You can verify that both containers are running smoothly by checking the container logs:
Once the containers are operational, you need to download an open-source language model into Ollama. For an 8GB RAM VPS, Meta's Llama 3 (8B) or Mistral's Mistral-7B are the optimal choices.
Run the following command inside the Ollama container to pull the Llama 3 weights:
Depending on your VPS network speed, downloading the ~4.7GB model will take a minute or two. Once the download completes, you'll see an interactive prompt. You can type a quick test message or exit the interactive prompt by typing /bye.
Step 4: Securing Your Open WebUI Instance
By default, Open WebUI is now accessible on port 3000 of your VPS IP address (http://your_vps_ip:3000). Do not leave it exposed to the raw internet without protection. Anyone who discovers your IP address could use your server compute resources or view your prompts.
Let's set up basic firewall rules using UFW and then route traffic through a secure reverse proxy with SSL encryption.
First, configure your UFW firewall:
Notice that we did not open port 3000 or 11434 directly to the public internet. Instead, we will install Caddy - an automatic HTTPS reverse proxy - to handle incoming web traffic securely.
Install Caddy on your Ubuntu host:
Next, configure your domain name to point to your VPS IP address via your DNS provider (e.g., ai.yourdomain.com). Then, edit the Caddy configuration file:
Replace the default contents with your domain and local routing rule:
Save the file and restart the Caddy service:
Caddy will automatically provision a valid SSL/TLS certificate via Let's Encrypt. You can now navigate to https://ai.yourdomain.com in your web browser with complete transport-layer encryption.
Step 5: Configuring Open WebUI and User Management
When you first navigate to your new Open WebUI URL, you'll be greeted by a registration screen.
- Click Sign Up to create the initial administrator account. The very first account registered on a fresh Open WebUI instance automatically receives administrator privileges.
- Log in with your new credentials.
- Click your profile icon in the bottom-left corner, select Admin Panel, and navigate to Settings.

In the Admin Panel, you can toggle several crucial security settings:
- Allow New Account Sign-Ups: Toggle this OFF if you are the sole user or if you want to manually invite team members via the admin dashboard. This prevents random web scrapers from registering on your private instance.
- Default User Role: Set new invited users to "User" rather than "Admin" to restrict system configuration changes.
- Models: Verify that Ollama is correctly connected by checking the model dropdown in the top left of the chat window. You should see
llama3:latestready for action.
If you ever need to integrate external APIs (like adding optional fallback access to OpenAI or Anthropic keys for heavy coding tasks), you can configure them under the Admin Panel > Settings > Connections tab without exposing your primary local models.
Performance Tuning and Maintenance
Running AI models on a budget VPS means you need to be mindful of resource consumption. Here are three maintenance best practices I've established across our internal testing nodes:
1. Setting Up Automatic Model Unloading
By default, Ollama keeps loaded models in RAM for a set duration after your last prompt to speed up subsequent queries. If your VPS has tight memory constraints, you can adjust how long models stay resident by modifying your Docker environment variables in docker-compose.yml:
This ensures that Ollama unloads the model from RAM after 5 minutes of inactivity, freeing up memory for other system processes.
2. Routine Log Rotation
Docker container logs can swell over time and fill up your NVMe storage disk. Add log constraints to your docker-compose.yml services:
3. Automated Backups
Your chat history, user profiles, and vector embeddings live inside the open_webui_data Docker volume. Back this directory up weekly using a simple cron script that compresses the volume data and pushes it to an encrypted remote bucket or local storage device.
For more insights on securing your tech stack and optimizing remote workflows, explore our archives on remote infrastructure management.
Conclusion
Self-hosting Ollama and Open WebUI on a cheap VPS strips away the recurring subscription bloat and data privacy risks of commercial AI tools. For less than $10 a month, you retain absolute ownership of your prompts, your code snippets, and your data pipelines.
Set aside an hour this weekend, spin up an instance, and take back control of your AI workflow.
Frequently Asked Questions
How much RAM do I need on a VPS to run Ollama smoothly?
You need at least 8GB of RAM to run 7B or 8B parameter models like Llama 3 or Mistral without severe performance degradation. For 13B models or higher, step up to 16GB or 32GB RAM instances.
Can I run Ollama on a VPS without a dedicated GPU?
Yes, you can run Ollama on a CPU-only VPS, but generation speeds will be slower (typically 5 to 15 tokens per second depending on core count and RAM bandwidth). For faster inference, look for dedicated GPU instances or cloud providers with vGPUs.
How do I secure my Open WebUI installation from unauthorized public access?
You should never expose port 3000 directly to the internet without protection. Use a reverse proxy like Nginx Proxy Manager or Caddy, enforce strong password policies, disable public sign-ups in the Open WebUI settings, and implement fail2ban.
Which VPS providers offer the best price-to-performance ratio for self-hosting AI models?
Hetzner and DigitalOcean offer reliable CPU instances with high memory configurations at predictable hourly or monthly rates, while Vultr and RunPod provide dedicated GPU nodes if you require faster token generation speeds.
What is the exact command to pull a model like Llama 3 inside Ollama?
Once your Ollama container is running via Docker, you run 'docker exec -it ollama ollama run llama3' or connect directly through the Open WebUI model management interface to pull models with a single click.
How do I back up my Open WebUI chat history and vector database?
Open WebUI stores all configuration, user data, and vector embeddings in a Docker volume. You can back this up by mounting the volume directory and running a standard tar or rsync cron job to your secure local storage.
Frequently Asked Questions
You need at least 8GB of RAM to run 7B or 8B parameter models like Llama 3 or Mistral without severe performance degradation. For 13B models or higher, step up to 16GB or 32GB RAM instances.
Yes, you can run Ollama on a CPU-only VPS, but generation speeds will be slower (typically 5 to 15 tokens per second depending on core count and RAM bandwidth). For faster inference, look for dedicated GPU instances or cloud providers with vGPUs.
You should never expose port 3000 directly to the internet without protection. Use a reverse proxy like Nginx Proxy Manager or Caddy, enforce strong password policies, disable public sign-ups in the Open WebUI settings, and implement fail2ban.
Hetzner and DigitalOcean offer reliable CPU instances with high memory configurations at predictable hourly or monthly rates, while Vultr and RunPod provide dedicated GPU nodes if you require faster token generation speeds.
Once your Ollama container is running via Docker, you run 'docker exec -it ollama ollama run llama3' or connect directly through the Open WebUI model management interface to pull models with a single click.
Open WebUI stores all configuration, user data, and vector embeddings in a Docker volume. You can back this up by mounting the volume directory and running a standard tar or rsync cron job to your secure local storage.

Alex Morgan is the founder and lead editor of RemoGrid. With over six years of hands-on experience in remote operations, cross-border freelance workflows, and AI tool benchmarking, Alex independently tests and audits software platforms to help modern digital workers build sustainable online income streams. He regularly reviews international payment systems (Wise, Stripe, Payoneer, local mobile wallets) and conducts real-world usability benchmarks across AI productivity tools.


