Skip to content

Offer: your first month of web hosting is free on monthly plans. Order by 7 Jan. See plans

HostEthical
All guides

Guides 15 min read ·

VPS for Ollama: Self-Host Your Own LLM on a CPU Server with Open WebUI

Run Ollama on a CPU-only VPS in 2026: what fits in 8, 12 and 24 GB RAM, install on Ubuntu 24.04, keep the API private, add Open WebUI with HTTPS.

The most important thing in a VPS for Ollama is RAM, because without a GPU the whole model sits in system memory and runs on the CPU. On a CPU-only server, small quantised models (about 3B to 9B parameters) work for private chat, embeddings and light automation, 20B to 27B models fit in 24 GB but answer slowly, and large models or many simultaneous users need a GPU server or a pay-per-token API. HostEthical's Cloud VPS plans have no GPU, so this guide sticks to what CPU inference can do, then sets up Ollama on localhost with Open WebUI behind Nginx and HTTPS.

This guide uses Ollama 0.40.17 and Open WebUI 0.13.4, the latest releases as of 23 November 2026, with Docker Engine, Nginx and certbot on Ubuntu 24.04 LTS. For a brand-new server, start with how to set up a VPS.

Can you run an LLM on a VPS without a GPU?

Yes. Ollama runs models on CPU cores alone when there's no GPU. If the install script finds no graphics card, it prints "No NVIDIA/AMD GPU detected. Ollama will run in CPU-only mode." and carries on. With a model loaded, ollama ps shows 100% CPU, which Ollama's FAQ explains as "loaded entirely in system memory".

The catch is speed. For every token it writes, the model works through its weights, and a CPU does that much more slowly than a GPU, so bigger models are slower. We don't quote tokens-per-second figures because they depend on the model, quantisation, prompt and CPU; ollama run MODEL --verbose prints timings on your own server.

CPU inference handles these well:

  • Private chat for one person or a small team, with a 3B to 9B model.
  • Embeddings for search and RAG (retrieval-augmented generation): embeddinggemma is just 622 MB.
  • Background automation, such as tagging tickets or summarising emails, where nobody watches the answer appear.

It handles these badly:

  • Many users at once. On a Linux server OLLAMA_NUM_PARALLEL defaults to 1, so each model answers one request at a time and the rest queue (FAQ).
  • Large models, such as 70B-class models, which don't fit in 24 GB.
  • Agents and coding tools. Ollama's context length page recommends at least 64,000 tokens for "web search, agents, and coding tools", against a default of 4,096, and more context needs more memory and time.

Best VPS for Ollama: what fits on 8, 12 and 24 GB of RAM?

Ollama's docs don't publish a RAM table per model size. The useful number is the download size on each model's tags page in the Ollama library, because the weights must fit in RAM, and the context needs memory on top ("Setting a larger context length will increase the amount of memory required"). Our rule of thumb, not an official figure: keep at least 4 GB free beyond the model file for Ubuntu, Docker, Open WebUI and the context. Then check real usage with ollama ps (SIZE column) and free -h.

RAMModels that fit comfortably (tag, download size)Good for
8 GB (VPS Starter)llama3.2:3b (2.0 GB), qwen3.5:4b-q4_K_M (3.3 GB), embeddinggemma (622 MB)Embeddings, classification, short summaries, simple chat
12 GB (VPS Pro)qwen3.5:9b-q4_K_M (6.6 GB), gemma4:e4b-it-q4_K_M (6.6 GB); gemma4:12b-it-q4_K_M (8.0 GB) is tight, using the whole 12 GB by our rule of thumbBetter writing and chat for one person, questions over documents
24 GB (VPS Max)gpt-oss:20b (14 GB), qwen3.5:27b-q4_K_M (17 GB), gemma4:26b-a4b-it-q4_K_M (18 GB), or a 9B model plus an embedding modelThe strongest models a CPU server can hold, for patient users

Sizes are from the tags pages for Llama 3.2, Qwen 3.5, Gemma 4, gpt-oss and EmbeddingGemma, checked 23 November 2026.

  • q4_K_M is a 4-bit quantisation: a smaller file with some loss of quality. Qwen 3.5 9B is 6.6 GB at q4_K_M and 10 GB at q8_0. Plain tags such as qwen3.5:9b show a size range, so naming the q4_K_M build pins the exact file.
  • Mixture-of-experts models use only part of their weights per token. Ollama's Gemma 4 page lists the 26B A4B with 25.2B parameters in total and 3.8B active, which makes it worth trying on a CPU. gpt-oss is mixture-of-experts too, and its page says the 20B version runs "on systems with as little as 16GB memory".
  • Too big for 24 GB in practice: gemma4:31b (19 to 20 GB) and qwen3.5:35b (22 GB).
  • Indian languages: the Qwen 3.5 page claims 201 languages and dialects without listing them, so test Hindi or your language first.

How to install Ollama on Ubuntu 24.04, step by step

Run these as your sudo user, not root.

1. Install the tools the installer needs

sudo apt update && sudo apt upgrade -y
sudo apt install -y curl zstd

Ollama now ships .tar.zst archives, and the install script stops with an error if zstd is missing.

2. Run the official install script

curl -fsSL https://ollama.com/install.sh -o ollama-install.sh
less ollama-install.sh            # optional: read it first, q to quit
sh ollama-install.sh
ollama -v
systemctl status ollama --no-pager

This is the method in Ollama's Linux docs, downloaded first so you can read it. The script installs Ollama under /usr/local, creates an ollama system user, writes /etc/systemd/system/ollama.service with Restart=always, and enables and starts it. Models go in /usr/share/ollama/.ollama/models. To update, run the script again; logs are in journalctl -e -u ollama.

3. Keep Ollama bound to localhost

By default Ollama listens on 127.0.0.1, port 11434, so only programs on the server can reach it. Keep it that way: Ollama's API docs say "The local API at http://localhost:11434 does not require authentication." Set OLLAMA_HOST=0.0.0.0 on a public server and anyone who finds the port can use your CPU, pull models onto your disk and delete yours.

Put your settings in a systemd override, which survives updates because the installer only rewrites ollama.service:

sudo mkdir -p /etc/systemd/system/ollama.service.d
sudo tee /etc/systemd/system/ollama.service.d/override.conf > /dev/null <<'EOF'
[Service]
Environment="OLLAMA_HOST=127.0.0.1:11434"
Environment="OLLAMA_KEEP_ALIVE=30m"
Environment="OLLAMA_NO_CLOUD=1"
EOF
sudo systemctl daemon-reload
sudo systemctl restart ollama
ss -tln | grep 11434              # must show 127.0.0.1:11434, never 0.0.0.0 or *

OLLAMA_HOST repeats the default so the intent is written down. OLLAMA_KEEP_ALIVE=30m keeps a model in memory for 30 minutes after its last request, instead of 5, so it reloads from disk less often. OLLAMA_NO_CLOUD=1 turns off Ollama's cloud models and web search, so prompts only go to models on your server. For access from your laptop, use an SSH tunnel rather than opening the port: ssh -N -L 11434:127.0.0.1:11434 deploy@your-server-ip.

4. Pull and run a model

ollama pull qwen3.5:4b-q4_K_M
ollama run qwen3.5:4b-q4_K_M --think=false --verbose "Explain what a VPS is in two sentences."
ollama ps                         # SIZE = memory in use, PROCESSOR = 100% CPU
ollama list                       # models on disk; ollama rm NAME deletes one

Leave out the quoted prompt to chat interactively; /bye quits. Qwen 3.5 is a "thinking" model that can write out its reasoning before answering, which costs time on a CPU. --think=false asks for the answer alone; per Ollama's docs, models that can't turn thinking off use their lowest level.

How do you call the Ollama API from an app on the same server?

Any app, cron job or n8n workflow on the VPS can call http://127.0.0.1:11434 directly. The native chat endpoint:

curl http://127.0.0.1:11434/api/chat -d '{
  "model": "qwen3.5:4b-q4_K_M",
  "messages": [{"role": "user", "content": "Classify this ticket as billing, technical or other: my invoice shows the wrong GST number."}],
  "think": false,
  "stream": false
}'

Ollama also speaks the OpenAI API at /v1, so existing code mostly needs a new base URL. Per the compatibility docs, the client requires an API key value but Ollama ignores it. On Ubuntu 24.04, install the Python client in a virtual environment:

sudo apt install -y python3-venv
python3 -m venv ~/llm-app/.venv
source ~/llm-app/.venv/bin/activate
pip install openai
# ~/llm-app/app.py
from openai import OpenAI

client = OpenAI(base_url="http://127.0.0.1:11434/v1", api_key="ollama")  # required but ignored
reply = client.chat.completions.create(
    model="qwen3.5:4b-q4_K_M",
    messages=[{"role": "user", "content": "Summarise in one line: the customer wants a refund for a duplicate order."}],
)
print(reply.choices[0].message.content)

For search or RAG, create embeddings with /api/embed, using the same embedding model for indexing and queries as Ollama's embeddings docs advise:

ollama pull embeddinggemma
curl http://127.0.0.1:11434/api/embed -d '{
  "model": "embeddinggemma",
  "input": ["Refunds are processed within 7 days.", "How do I get my money back?"]
}'

Agents can use the same API: Ollama's integration docs show ollama launch openclaw and ollama launch hermes, and n8n has an Ollama node. Given the 64,000-token recommendation, expect agents on a local CPU model to be slow. See OpenClaw on a VPS, Hermes Agent on a VPS, Claude Code on a VPS and n8n pricing in India. One trap: n8n in Docker on the default network can't reach 127.0.0.1 on the host; host networking, used for Open WebUI below, solves it.

How do you put Open WebUI behind Nginx with HTTPS?

Open WebUI is a self-hosted chat interface with user accounts and chat history. Nginx handles HTTPS, Open WebUI listens on localhost, and its backend calls Ollama, so browsers never touch port 11434 (as its hardening guide notes). First point an A record for chat.example.com at the server (see DNS records explained).

5. Install Docker Engine

From Docker's official apt repository; our Docker on a VPS guide explains each line.

sudo apt install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

6. Open only SSH, HTTP and HTTPS in ufw

sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
sudo ufw status verbose

Allow SSH before enabling, or you'll lock yourself out, and don't open 8080 or 11434. The Docker catch: Docker's documentation says published container ports bypass ufw. Open WebUI's quick-start command uses -p 3000:8080, which would put port 3000 on the internet whatever ufw says, and the ollama/ollama image with -p 11434:11434 would expose your unauthenticated API. The set-up below publishes nothing: Docker creates no firewall rules for host networking, so ufw stays in charge. For other containers, publish like -p 127.0.0.1:3000:8080.

7. Create the Nginx site

Run sudo apt install -y nginx, then create /etc/nginx/sites-available/chat.example.com:

server {
    listen 80;
    listen [::]:80;
    server_name chat.example.com;

    client_max_body_size 20M;                  # largest file you can upload in a chat

    location / {
        proxy_pass http://127.0.0.1:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;    # Open WebUI streams over a WebSocket
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $remote_addr;   # overwrite, so visitors can't fake an IP
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_buffering off;
        proxy_read_timeout 10m;                    # long CPU answers can take minutes
    }
}
sudo ln -s /etc/nginx/sites-available/chat.example.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Open WebUI's Nginx guide uses the Upgrade and Connection headers for its WebSocket and turns proxy buffering off, and its HTTPS reference asks for read timeouts of at least 300 seconds. The site shows a 502 error until Open WebUI runs.

8. Turn on HTTPS with Let's Encrypt

sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d chat.example.com
sudo certbot renew --dry-run

Certbot gets the certificate and adds it to your Nginx config. Let's Encrypt certificates last 90 days, and 64 days from 10 February 2027, so renewal has to be automatic: Ubuntu's certbot package installs a systemd timer that does it, and the dry run confirms renewal works. Background: what is an SSL certificate.

9. Start Open WebUI on localhost

Keep the settings in a root-only file, so the secret key survives updates:

sudo tee /etc/open-webui.env > /dev/null <<EOF
HOST=127.0.0.1
PORT=8080
OLLAMA_BASE_URL=http://127.0.0.1:11434
WEBUI_URL=https://chat.example.com
WEBUI_SECRET_KEY=$(openssl rand -hex 32)
WEBUI_AUTH_COOKIE_SECURE=true
WEBUI_SESSION_COOKIE_SECURE=true
EOF
sudo chmod 600 /etc/open-webui.env

sudo docker run -d --name open-webui --restart always \
  --network=host \
  --env-file /etc/open-webui.env \
  -v open-webui:/app/backend/data \
  ghcr.io/open-webui/open-webui:main

sudo docker logs -f open-webui    # Ctrl+C to stop watching
ss -tln | grep -E '8080|11434'    # both must show 127.0.0.1 only
  • --network=host puts the container on the server's network, so 127.0.0.1 inside it is the server's loopback. Open WebUI reaches Ollama there (the fix on Open WebUI's troubleshooting page), and HOST=127.0.0.1 keeps port 8080 private. The variable reference warns that this HOST value breaks bridge-network containers; with host networking it's correct.
  • A fixed WEBUI_SECRET_KEY stops a recreated container logging everyone out. With secure cookies on, always use the https:// address.
  • The open-webui volume holds chats, users and settings; back it up. To pin a release instead of the rolling :main, use a tag such as v0.13.4 (released 17 November 2026 and still the newest on 23 November).

10. Create the admin account straight away

Open https://chat.example.com and sign up at once: Open WebUI makes the first account the administrator, then switches sign-up off, so whoever reaches the page first takes control. To let colleagues in, turn on New Sign Ups under Settings, Authentication (admin section); new accounts wait as Pending until you approve them. If an app on another server needs the model, switch on API Keys in the same admin section, create a key under Settings, Account (see Open WebUI's API keys guide), and call Open WebUI over HTTPS rather than opening Ollama's port.

Run a private LLM on a server you control. VPS Max has 8 vCPU and 24 GB RAM for Ollama and Open WebUI, in Mumbai or Germany. See VPS plans →

When is a VPS the wrong choice for running an LLM?

  • A public chatbot with real traffic, where visitors would queue.
  • Top-quality answers. OpenAI's flagship GPT models, Claude and Gemini can't be downloaded at all, only used through hosted APIs, and the largest open models need GPU servers.
  • Agents and coding tools with long contexts. Use a hosted model and keep the VPS for the agent itself.
  • Fine-tuning, training or real-time voice.

In those cases, a GPU cloud server, rented by the hour or month, runs the same Ollama set-up much faster but costs considerably more, so it suits steady, heavy use. A pay-per-token API from OpenAI, Anthropic, Google or a host of open models costs nothing while idle and suits spiky or low volume. Ollama's own cloud models also work through the local API after ollama signin (drop OLLAMA_NO_CLOUD first); its FAQ says it doesn't store or log those prompts. A common middle path: keep embeddings and private documents on the VPS, and send only hard prompts to an API.

Why self-host your own LLM in India?

Control of your data. With local models, Ollama's FAQ says "We don't see your prompts or data", and Open WebUI keeps chats in a Docker volume on your server, while a hosted API sends every prompt to the provider, often outside India. On our Mumbai location, the model, prompts and chat history stay on a server in India that you control. That helps when clients ask where their data goes, though it doesn't make you compliant with any law by itself. Mumbai is also closer to Indian users (see VPS hosting in Mumbai), though on a CPU server the model's writing time matters far more than network distance. And you pay a fixed amount in rupees, not a dollar bill that grows with every token.

Running Ollama on HostEthical

HostEthical's Cloud VPS plans are unmanaged KVM servers with full root access, a dedicated IPv4 address, SSD storage and Ubuntu 24.04 LTS among the OS choices, built automatically after payment, usually within 5 to 15 minutes. None has a GPU. Plans start at ₹860 a month, or about ₹774.17 a month when billed yearly. You pay in rupees by UPI or binance Pay (USDT), and the price stays the same at renewal.

PlanvCPURAMStoragePaid monthlyPaid up front, per monthAt renewal
VPS Starter4 cores8 GB100 GB SSD₹860₹774.17 (yearly)Same price
VPS Pro6 cores12 GB200 GB SSD₹1,170₹1,053.33 (yearly)Same price
VPS Max8 cores24 GB300 GB SSD₹2,190₹1,971.67 (yearly)Same price

For local LLMs, VPS Max is the sensible pick. RAM decides which models you can run, and its 24 GB is the only plan that holds the 14 to 18 GB models above, or a 9B chat model, an embedding model and Open WebUI side by side with room for a longer context. Its 8 vCPU give Ollama more cores than VPS Starter's 4 or VPS Pro's 6, and its 300 GB SSD holds plenty of models. It's still a CPU server: right for one person or a small team, not a busy public chatbot.

VPS Starter's 4 vCPU and 8 GB cover embeddings and a 3B or 4B model for background jobs; VPS Pro's 12 GB suits a 9B model for your own use. Choose Mumbai to keep data in India, for ₹380 a month more than Germany; Germany is fine for a private assistant only you use. You can also register a domain with us and point chat.yourdomain.com at the server with our DNS editor.

Self-host your own LLM this week. Pick VPS Max, pay by UPI and follow the steps above. See Cloud VPS →

Frequently asked questions

Can Ollama run on a VPS without a GPU?

Yes. When Ollama finds no NVIDIA or AMD graphics card it runs in CPU-only mode with the model in system RAM, and ollama ps shows 100% CPU. Small quantised models of about 3B to 9B parameters are practical for private chat, embeddings and background jobs, while large models and many simultaneous users need a GPU server or a hosted API. HostEthical Cloud VPS plans are CPU-only.

How much RAM do I need to run Ollama?

Ollama does not publish a fixed table, so treat the download size on each model's tags page as the minimum and add a few gigabytes for Ubuntu, the context window and any web interface. As of November 2026, llama3.2:3b is 2.0 GB, qwen3.5:9b at q4_K_M is 6.6 GB and qwen3.5:27b at q4_K_M is 17 GB. After loading a model, check real usage with ollama ps and free -h.

Is it safe to expose the Ollama API to the internet?

No. Ollama's documentation says the local API on port 11434 does not require authentication, so anyone who can reach it can run, pull or delete models. Keep OLLAMA_HOST on 127.0.0.1, use an SSH tunnel for your own access, and give other people a front end with logins, such as Open WebUI behind Nginx and HTTPS.

How do I update Ollama and Open WebUI?

Update Ollama by running the official install script again: it replaces the program and leaves your models and your systemd override file in place. For Open WebUI, pull the image, remove the container with docker rm -f open-webui and start it again with the same docker run command. Chats and users live in the open-webui volume, and a fixed WEBUI_SECRET_KEY keeps everyone logged in.

Can I use Ollama with n8n or an AI agent on the same server?

Yes. n8n has an Ollama credential and node, and Ollama's docs show ollama launch commands that connect agents such as OpenClaw and Hermes Agent to http://127.0.0.1:11434. Ollama recommends a context window of at least 64,000 tokens for agents and coding tools, which needs much more memory and is slow on a CPU. For agents, a hosted model is often the better fit, with Ollama kept for embeddings and simple tasks.