Skip to content
Black FridayCode BLACK150: 150% on your first deposit of $100 or more, up to $500 bonus. New accounts, until 1 Dec, 00:00 UTC.Get the code
LiteKeep
Sign inDeploy a server

Tutorial, Ubuntu 24.04

Ollama on a VPS. Your own model API, on CPU or GPU, kept private.

Most Ollama VPS guides end with OLLAMA_HOST=0.0.0.0 and an open port. That publishes a free model API for anyone who scans for it. Here’s the setup that stays yours.

  • 10 min read
  • 5 chapters
  • Updated

What Ollama's docs say

  • Listens on127.0.0.1, port 11434Local only
  • Local API loginRequests are not checkedNone
  • Context, small GPUsDefault length4,096

So keep it local, and put a key in front if you open it.

Ollama on a Lite 16

$20

  • 16 GB RAM
  • Qwen3 14B
  • Llama 3.1
  • Gemma 3
  • DeepSeek-R1
  • Mistral

Fits 14B models on CPU by our sizing rule. Billed by the hour.

The short answer

Install with Ollama’s one-line script, pull a model, and call its API on port 11434 of the server itself. It runs on CPU with no GPU at all; the model has to fit in RAM, so a 16 GB server runs models up to about 14B.

Ollama doesn’t check local API requests, so never open port 11434 to the internet. Use an SSH tunnel, or a proxy that checks a key: the builder below writes both.

Ollama downloads open models and serves them through an API, its own and an OpenAI-compatible one. On a VPS it becomes a model endpoint for your apps, agents and scripts that runs all day.

The two things to get right are memory, because the model lives in RAM or GPU memory, and access, because the API has no login of its own.

In this guide you’ll learn

  • CPU or GPU, and which models fit
  • Install and check it’s running
  • Call the API, native and OpenAI-style
  • A settings builder for private remote access
  • Fixes for the common errors

Chapter 1

CPU or GPU: which server for Ollama?

Ollama runs on CPU when there’s no GPU, using system RAM. A GPU is faster, but only for what fits in its memory: a bigger model splits between GPU and RAM, and ollama ps shows the split.

What runs fully, by our sizing rule (model file size plus cache, with 2 GB kept for the system)
ServerMemoryBiggest that runs fullyPrice
Lite 88 GB RAM8B models (Llama 3.1 8B, Qwen3 8B)$12 a month
Lite 1616 GB RAM14B models (Qwen3 14B, Phi-4)$20 a month
Lite 3232 GB RAM30B (Qwen3 30B, Gemma 3 27B)$40 a month
Forge L40S8 GB GPU, 32 GB RAM8B on the GPU; bigger ones split$400 a month

Every model and plan is in our model fit tool. We don’t publish speed figures we haven’t measured. Measure yours in one command: ollama run llama3.2:3b --verbose prints an “eval rate” in tokens a second.

Chapter 2

Install Ollama on Ubuntu

The official script installs Ollama, creates an ollama user and a systemd service, and starts it. With no GPU it says so and runs in CPU mode.

  1. Install

    curl -fsSL https://ollama.com/install.sh | sh
  2. Check it runs

    systemctl status ollama
    ollama --version
  3. Pull and try a model

    ollama pull llama3.2:3b
    ollama run llama3.2:3b "Say hello in five words"

Models are stored in /usr/share/ollama/.ollama/models. Logs: journalctl -e -u ollama. To update, run the install script again.

Chapter 3

Call the Ollama API

Ollama serves two APIs on port 11434: its own under /api, and an OpenAI-compatible one under /v1, so most OpenAI clients work by changing the base URL.

  1. List your models

    curl http://127.0.0.1:11434/api/tags
  2. Chat, the Ollama way

    curl http://127.0.0.1:11434/api/chat -d '{"model": "llama3.2:3b", "messages": [{"role": "user", "content": "Hello"}], "stream": false}'
  3. Chat, the OpenAI way

    curl http://127.0.0.1:11434/v1/chat/completions -H "Content-Type: application/json" \
      -d '{"model": "llama3.2:3b", "messages": [{"role": "user", "content": "Hello"}]}'
  4. See what is loaded

    ollama ps

    It shows each loaded model and where it runs: 100% CPU, 100% GPU, or a split.

Chapter 4

Settings and private remote access

Ollama listens on 127.0.0.1 by default, and its docs say local requests need no authentication. Keep it that way, and choose how you reach it: an SSH tunnel for you alone, or a proxy that checks a key for apps elsewhere.

Your setup

1. sudo systemctl edit ollama, paste, save

[Service]
Environment="OLLAMA_HOST=127.0.0.1:11434"
Environment="OLLAMA_NUM_PARALLEL=1"
Environment="OLLAMA_CONTEXT_LENGTH=4096"
Environment="OLLAMA_KEEP_ALIVE=5m"
sudo systemctl daemon-reload && sudo systemctl restart ollama

2. Connect from your computer

ssh -N -L 11434:127.0.0.1:11434 you@your-server-ip
# then, on your computer:
curl http://localhost:11434/api/tags

Deploy a Lite 16

For the proxy, install Caddy (sudo apt install -y caddy), point your domain at the server, paste the Caddyfile and run sudo systemctl reload caddy. Caddy gets the HTTPS certificate itself. Then open only ports 22, 80 and 443 in your firewall.

Chapter 5

Common Ollama errors on a server

The problems people hit most, and what to check.

  1. Killed, or out of memoryHow to check: The model plus its cache didn’t fit. Use a smaller model, lower the context, or set OLLAMA_MAX_LOADED_MODELS=1 so switching models doesn’t keep two in memory. Adding swap stops the crash but is slow.
  2. 100% CPU on a GPU serverHow to check: Check nvidia-smi first. If the GPU is fine, the model is bigger than GPU memory: ollama ps shows the split. Pick a smaller model.
  3. 403 behind a proxyHow to check: Some setups need the proxy to send Host 127.0.0.1:11434; the Caddyfile above does.
  4. Slow answersHow to check: On CPU, smaller models answer faster. Measure with --verbose, then try a 3B or 4B model before buying a bigger server.

MythOllama needs a GPU.

Fact

It runs on CPU with system RAM; the installer says so when there’s no GPU.

MythSetting an API key in the client secures Ollama.

Fact

Ollama ignores it. Only the network setup secures it.

Now it’s your move

Install with one script, pick a model that fits your memory, keep the API on 127.0.0.1, and reach it through a tunnel or a key-checking proxy.

Want a chat interface on top? A private AI server adds Open WebUI in one click. Serving many users at once on a GPU? Compare vLLM and Ollama.