21+ years in hosting · Jaipur, India · INR billing with 18% GST · 24/7 email support
Blog · WebJi® India

Run an LLM on a VPS

Quick answer

To run an LLM on a VPS, install Ollama on Ubuntu, pull a 4-bit model and size RAM to it: about 4 GB for a 3B model, 8 GB for 7–8B and 12–16 GB for 13B. Keep the Ollama API on 127.0.0.1 behind Nginx with HTTPS, because Ollama has no authentication.

For developers and small teams who want a private, self-hosted language model on their own server for summaries, chat or automation.

✓ In business since 2005
✓ INR + GST billing
✓ 24/7 Email Support — avg reply < 60 min
GuideWebJi®
knowledge
Read time
4 min
Sections
9
Updated
14 Nov 2026
Written by
WebJi® team

What does a VPS need to run an LLM?

RAM decides whether a model runs at all, CPU cores decide how fast it answers, and disk only decides how long the download takes. The model's weights must fit in memory with room left for the operating system and the context window.

  • RAM: the model's file size plus about 1.5–2 GB for the system and context.
  • vCPU: four cores is a practical floor for CPU-only inference; speed improves with more cores and newer CPUs.
  • Disk: NVMe, with 20 GB or more for two small models; spinning disks make each model load slowly.
  • Swap: 2 GB as a safety net so a model that overshoots RAM does not freeze the SSH session.
  • GPU (optional): turns seconds-per-answer into near-instant replies; needed for larger models at chat speed.

How much RAM does each model size need?

At 4-bit quantisation, plan about 4 GB of RAM for a 3B model, 8 GB for a 7–8B model, 12–16 GB for a 13–14B model and 48–64 GB for a 70B model. Quantisation stores each weight in roughly half a byte, which is why a 7B model shrinks from about 14 GB at 16-bit to under 5 GB.

Planning figures for 4-bit models (arithmetic for sizing, not a benchmark)
ParametersApprox. downloadRAM to plan (CPU)GPU VRAM
3B (e.g. llama3.2:3b)~2 GB4 GB4–6 GB
7–8B~4.5–5 GB8 GB8 GB
13–14B~8–9 GB12–16 GB12–16 GB
30–34B~19–20 GB32 GB24 GB
70B~40–43 GB48–64 GB2 × 24 GB or more

Long context windows add memory on top of the weights. If a model barely fits, lower the context size before buying a bigger server. How much RAM a VPS needs covers sizing for the rest of the stack.

How do you install Ollama on an Ubuntu VPS?

Run Ollama's install script, which places the binary and a systemd service; the API then listens on 127.0.0.1:11434, reachable only from the server itself. Use a fresh Ubuntu 24.04 server with sudo access.

sudo apt update && sudo apt upgrade -y
curl -fsSL https://ollama.com/install.sh | sh

# Check the service and the listening address
systemctl status ollama
ss -lntp | grep 11434      # should show 127.0.0.1:11434
ollama --version

If ss shows 0.0.0.0:11434, someone has changed OLLAMA_HOST; set it back before going further, because the Ollama API has no authentication.

How do you pull and test a first model?

Start with a small model such as llama3.2:3b (about 2 GB) to prove the whole path, then move up once the API answers. The default tags are 4-bit builds.

ollama pull llama3.2:3b
ollama run llama3.2:3b "Summarise in one line: our office moves to Pune on Monday."

# Test the HTTP API the way an app would call it
curl -s http://127.0.0.1:11434/api/generate \
  -d '{"model":"llama3.2:3b","prompt":"hello","stream":false}'

# Watch memory while it answers
free -h
ollama ps

A JSON reply with a response field means the API works. If RAM is full and swap keeps growing, switch to a smaller model or a server with more memory.

How do you add a chat interface with Open WebUI?

Run Open WebUI in Docker on the same server, connect it to Ollama on 127.0.0.1, and publish it only through Nginx with HTTPS. Host networking lets the container reach Ollama's loopback address without exposing Ollama.

# Install Docker (official convenience script)
curl -fsSL https://get.docker.com | sh

# Run Open WebUI on the host network; the UI listens on port 8080
docker run -d --network=host \
  -e OLLAMA_BASE_URL=http://127.0.0.1:11434 \
  -v open-webui:/app/backend/data \
  --name open-webui --restart always \
  ghcr.io/open-webui/open-webui:main

Keep port 8080 closed in the firewall and proxy a domain such as ai.example.com to http://127.0.0.1:8080 in Nginx, with a certificate from Certbot. Avoid the common -p 3000:8080 form on a public server: Docker's published ports bypass ufw rules. Create the first account yourself immediately, because the first sign-up becomes the administrator.

How do you expose the LLM safely?

Never open port 11434 to the internet: anyone who can reach it can run any model on your CPU at no cost to them. Put Nginx in front with HTTPS and authentication, and allow only SSH and web traffic through the firewall.

  1. Firewall: sudo ufw allow OpenSSH && sudo ufw allow 'Nginx Full' && sudo ufw enable
  2. For apps that call the API, proxy /api/ to 127.0.0.1:11434 and add basic auth: sudo htpasswd -c /etc/nginx/.htpasswd apiuser (from the apache2-utils package), then auth_basic in the server block.
  3. Add limit_req in Nginx so one client cannot queue long prompts that tie up the model for minutes.
  4. Check from outside the server that 11434 and 8080 do not answer.

How fast is CPU-only inference?

On four to eight modern cores, expect roughly 5–15 tokens a second from a 7B model and 2–6 tokens a second from a 13B model; real figures depend on the CPU generation, memory bandwidth and context length. That is fine for summaries, classification and background jobs, and slow for long interactive chats.

  • Keep models loaded: set OLLAMA_KEEP_ALIVE=30m in the service environment so the next request does not wait for a reload (the default is 5 minutes).
  • Trim context: lower num_ctx to what prompts actually use; large contexts cost memory and time.
  • Batch work: run bulk jobs overnight rather than expecting chat speed from a CPU box.
  • Use a GPU when speed matters: see CPU vs GPU and WebJi® GPU VPS options.

Is self-hosting an LLM cheaper than a paid API?

Self-hosting pays off when data must stay on your own infrastructure, when monthly API spend exceeds the server cost, or when you need the model available regardless of a third-party service; for low or spiky usage, a paid API is usually cheaper. A server costs the same whether it answers a thousand requests or none.

A WebJi® KVM VPS gives root access for Ollama, Docker and Nginx, with plans from ₹499 a month before 18% GST; choose a size that matches the RAM table above rather than the cheapest plan, and ask support@webji.services for larger configurations. If the same server will also run other services, plan their memory too: self-hosting Supabase and installing n8n each need their own headroom.

FAQ

Frequently asked questions

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

Yes. Quantised 3B to 8B models run on CPU at a few to about fifteen tokens a second on four to eight cores. That suits summaries, tagging and background tasks; interactive chat feels slow, and very large models need far more RAM than a small VPS has.

Which models run well on CPU only?

The 3B and 7–8B families at 4-bit, such as Llama 3.2 3B, Qwen 2.5 7B and Mistral 7B, fit in 8 GB of RAM and answer in seconds. Larger models run, but at speeds better suited to batch jobs.

Is my data sent anywhere when I use Ollama?

No. Prompts and answers stay on your server; the model runs locally after it is downloaded. Network access is needed only to pull models and updates, which is the main reason businesses self-host.

How do I update Ollama and the models?

Re-run the install script to update Ollama, then ollama pull the model name again to fetch the latest version of that tag. For Open WebUI, pull the new image and recreate the container; its data stays in the open-webui volume.

Commands checked against the Ollama install script and the Open WebUI README · Reviewed by the WebJi® team, Jaipur, 15 November 2026.

WebJi® since 2005

Ready to get started with WebJi®?

Join 12,000+ businesses across India and overseas. INR pricing, 18% GST shown before payment and 24/7 email support in Hindi and English — average first reply under 60 minutes.