You are currently viewing How to Self Host Ollama on a VPS: Complete Guide 2026
Self Host Ollama

How to Self Host Ollama on a VPS: Complete Guide 2026

Self Hosting • AI Infrastructure

How to Self-Host Ollama on a VPS: Setup, Security, Performance & Cost

Want to run an open-source AI model on infrastructure you control? This practical guide explains how to self-host Ollama on a VPS, choose between CPU and GPU hosting, secure the API, connect your applications and understand what kind of performance you can realistically expect.

VS
Vanel Sylvestre
Updated: 2026 Approx. 15 minute read
Your Private AI Stack Browser / App → HTTPS → VPS → Ollama → Local Model Your App Python • n8n Web App • SaaS Your VPS Caddy + HTTPS Ollama API LLM Model Llama • Gemma Mistral • gpt-oss Prompts and model execution remain on infrastructure you control.
TL;DR

Ollama makes running open language models on your own machine surprisingly simple. A CPU VPS can be enough for private automations and lightweight models, while an NVIDIA GPU server is a much better option for interactive chat or multiple simultaneous users. Keep Ollama bound to localhost, protect remote access with HTTPS and authentication, and choose your server based on model size, desired context length and concurrency rather than CPU count alone.

What you will have when you’re finished

  • A working Ollama installation on your own VPS.
  • At least one open-source LLM downloaded and ready to use.
  • A private API endpoint instead of an exposed port 11434.
  • HTTPS access through a reverse proxy.
  • A practical understanding of CPU versus GPU hosting.
  • An API that can be connected to Python, n8n or your own SaaS.

Why Self-Host Ollama?

Cloud AI APIs are convenient, but they also place the model, infrastructure and pricing structure outside your control. With Ollama, the model runs on a server that you manage. That can be useful when privacy, predictable infrastructure costs or deep application integration matters more than having access to the largest commercial models.

Ollama provides a straightforward runtime for downloading and serving popular open models. Instead of manually configuring inference engines, model formats and server processes, you can pull a model with a single command and immediately communicate with it through a local API.

🔒

More Control

You determine where the model runs, how it is exposed and what applications have access to it.

No Per-Token Meter

Your primary cost becomes infrastructure rather than paying separately for each API request.

Easy Integration

Ollama exposes APIs that can be connected to automation tools, scripts and web applications.

What Do You Need to Self-Host Ollama?

The right server depends heavily on the model you plan to run. A small 3B-class quantized model is much easier to host than a 20B, 32B or 70B model. RAM and VRAM usually matter more than simply buying the VPS with the highest number of CPU cores.

Use Case Suggested Starting Point Best For
Learning / testing 4 vCPU, 8 GB RAM Small models and experiments
Personal automation 8 vCPU, 16 GB RAM Summaries, classification, background AI jobs
Interactive AI chat NVIDIA GPU with 16–24 GB VRAM Fast response generation
Multi-user application 24 GB+ GPU VRAM Concurrent inference
Important: Do not choose a VPS based only on the number of CPU cores. LLM inference can be extremely memory-bandwidth intensive. A GPU with enough VRAM can outperform a CPU server by a very large margin for interactive generation.

Step 1: Create Your VPS

1

Choose Ubuntu

Ubuntu 22.04 or a recent Ubuntu LTS release is a convenient choice because Ollama, Caddy, Docker and most supporting tools are well documented on Ubuntu.

2

Select CPU or GPU infrastructure

If your goal is experimentation or background automation, begin with CPU infrastructure. If you expect real-time chat responses, consider a GPU instance from the beginning.

3

Add your SSH key

SSH keys are preferable to relying on a reusable root password. Once your VPS is online, connect from your terminal.

Terminal
ssh root@YOUR_SERVER_IP

Need a VPS for Ollama?

CPU servers are available from many VPS providers, while GPU instances are offered by providers such as DigitalOcean and specialized GPU hosting platforms.

View DigitalOcean Servers →

Step 2: Install Ollama

Once the server is ready, Ollama’s Linux installer makes the initial installation very short.

Install Ollama
curl -fsSL https://ollama.com/install.sh | sh

After installation, verify that the service is available:

Check Ollama
ollama --version
systemctl status ollama

On a correctly configured installation, Ollama normally listens locally on port 11434. Keeping it local is desirable because we do not want the raw API exposed directly to the public internet.

Security principle: Keep Ollama itself private. Let a properly secured reverse proxy handle remote connections instead of publishing port 11434 directly.

Step 3: Download Your First AI Model

Ollama manages models using the ollama pull command. For a CPU server, start with a relatively small model before attempting a larger one.

Example model downloads
ollama pull llama3.2:3b

ollama pull llama3.1:8b

Then list installed models:

ollama list

You can start an interactive conversation directly from SSH:

ollama run llama3.2:3b

Test the local API

Local API request
curl http://127.0.0.1:11434/api/generate \
  -d '{
    "model": "llama3.2:3b",
    "prompt": "Explain self-hosted AI in one paragraph.",
    "stream": false
  }'

If you receive a JSON response containing generated text, the core Ollama server is working.

How Much RAM Does an Ollama Server Need?

Model size is one of the biggest factors in server sizing. Quantized models can reduce memory requirements substantially, but you still need room for the model, context cache, Ollama itself and the operating system.

Model Class Approximate Server Target Typical Use
1B–3B 8 GB RAM can be workable Basic assistants, extraction, classification
7B–8B 8–16 GB+ RAM General-purpose local AI
14B–20B 16–32 GB+ RAM / suitable GPU More capable generation and reasoning
30B+ Large RAM or high-VRAM GPU setup Advanced workloads

These are general planning ranges rather than hard guarantees. Exact requirements vary by quantization, model architecture, context size and concurrent requests.

Watch out for multiple models staying in memory

If you switch between several models on a small VPS, memory can become exhausted while the previous model remains loaded. For an inexpensive VPS, it is often safer to keep one primary model loaded rather than frequently jumping between multiple large models.

Step 4: Secure the Ollama API

A raw Ollama endpoint should not simply be opened to the internet. A better design keeps Ollama listening locally and places an HTTPS reverse proxy in front of it.

Configure the firewall

UFW firewall
ufw allow OpenSSH
ufw allow 80/tcp
ufw allow 443/tcp
ufw --force enable

ufw status

Notice that port 11434 is not opened. Public traffic should reach your proxy over 443, not Ollama directly.

Point a subdomain to your server

Create an A record such as:

ollama.yourdomain.com → YOUR_SERVER_IP

Once DNS is resolving correctly, you can configure a reverse proxy. Caddy is convenient because it can automatically provision HTTPS certificates.

Install Caddy

Follow the current official Caddy installation instructions for your Ubuntu version, then edit:

/etc/caddy/Caddyfile

Protect the endpoint with an authorization key

Example Caddy configuration
ollama.yourdomain.com {

    @authorized header Authorization "Bearer CHANGE-THIS-TO-A-LONG-SECRET"

    handle @authorized {
        reverse_proxy 127.0.0.1:11434 {
            header_up Host 127.0.0.1:11434
        }
    }

    handle {
        respond "Unauthorized" 401
    }
}

Reload Caddy after validating the configuration.

Validate and reload
caddy validate --config /etc/caddy/Caddyfile

systemctl reload caddy
Do not publish your real API key inside a WordPress article. The value above is only an example. Generate your own long random secret and store it privately in your applications.

Why the Host header matters

When Ollama sits behind a reverse proxy, requests can occasionally fail because the upstream application receives your public domain as the Host header. Setting the upstream Host to the local Ollama address helps avoid this class of reverse-proxy problem.

A Simpler Alternative: Use an SSH Tunnel

If only you need to use the server, you might not need to expose an HTTPS endpoint at all. An SSH tunnel lets a port on your local computer securely forward to Ollama on the VPS.

Run from your local computer
ssh -L 11434:127.0.0.1:11434 root@YOUR_SERVER_IP

You can then connect your local application to:

http://127.0.0.1:11434

For a single developer, this is one of the easiest ways to keep the Ollama endpoint completely private.

CPU vs GPU: What Kind of Performance Should You Expect?

The largest practical difference between an inexpensive CPU VPS and a GPU server is response speed. CPU inference can be perfectly acceptable for background jobs, but an interactive assistant feels dramatically better when the model is fully accelerated by a modern GPU.

Illustrative performance comparison

4-vCPU VPS
~3 tok/s
8-vCPU VPS
~7 tok/s
RTX 4000 Ada
~63 tok/s
RTX 6000 Ada
~143 tok/s
H100
~206 tok/s

Reference values above summarize publicly reported August 2026 llama3.1:8b benchmark results from LearnWithHasan. Hardware, model versions and settings can materially change performance.

Benchmark reference: LearnWithHasan – Self-Host an LLM with Ollama on a VPS . This article does not claim that the benchmark tests were performed independently by this website.

What Happens When Multiple Users Connect?

Single-user tokens per second tells only part of the story. If you plan to connect a SaaS product or team to Ollama, concurrency becomes extremely important.

A CPU system may continue generating roughly the same total number of tokens per second while multiple users divide that limited throughput. In practice, response latency can become frustrating very quickly.

GPUs can support parallel workloads far more effectively, provided there is enough VRAM for the model, context cache and number of parallel request slots.

A useful rule: increasing concurrency also increases memory requirements. Long context windows multiplied across many simultaneous requests can consume VRAM faster than expected.

Check whether the model is fully loaded on the GPU

GPU monitoring
nvidia-smi

curl http://127.0.0.1:11434/api/ps

If performance suddenly falls far below expectations, verify that the model has not been partially offloaded to system RAM and CPU.

Is Self-Hosting Ollama Cheaper Than Using an AI API?

Not automatically. This is one of the most important points to understand before renting expensive GPU infrastructure.

An API provider runs massive shared infrastructure with very high utilization. Your rented GPU may sit idle for hours, but you still pay for that idle capacity. As a result, self-hosting is not guaranteed to beat commercial APIs on raw cost per generated token.

💰

API

Often economical when usage is unpredictable or relatively low.

🖥

Self-Hosted

Attractive when predictable infrastructure and control matter.

🔐

Privacy

One of the strongest reasons to operate your own inference server.

Self-hosting becomes particularly appealing when you value data ownership, predictable infrastructure spending, custom model choices, internal applications, offline/private processing or freedom from per-request provider restrictions.

Which Ollama VPS Setup Should You Choose?

Option 1: Personal AI automations

Start small. A CPU VPS with 8–16 GB RAM and a 1B–3B model can handle tasks such as text categorization, draft generation, summaries and data extraction where nobody is waiting for tokens to stream onto the screen.

Option 2: Private ChatGPT-style assistant

For interactive conversation, an NVIDIA GPU with roughly 16–24 GB VRAM is a much more comfortable starting point. You will gain far faster token generation and enough headroom for more capable models.

Option 3: AI features inside a SaaS

Start with a GPU that can hold your entire model in VRAM. Benchmark actual concurrent workloads before launch, because the number of registered users is less important than how many requests arrive at the same moment.

Scenario Recommended Direction Priority
Private automation CPU + small model Low Cost
Personal interactive chat 16–24 GB VRAM GPU Speed
Small team 20–48 GB VRAM GPU Concurrency
Production AI SaaS Load-tested GPU infrastructure Scale

Step 5: Connect Ollama to Your Application

After the server is secured, Ollama can become the model layer behind your website, workflow automation, internal business application or AI SaaS.

Test your HTTPS endpoint

Remote request
curl https://ollama.yourdomain.com/api/generate \
  -H "Authorization: Bearer YOUR_PRIVATE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "llama3.2:3b",
    "prompt": "Write one sentence about private AI.",
    "stream": false
  }'

OpenAI-compatible endpoint

Ollama also supports OpenAI-compatible API routes, which makes it possible to use software originally designed for an OpenAI-compatible client by changing the base URL.

https://ollama.yourdomain.com/v1

Python example

Python
from openai import OpenAI

client = OpenAI(
    base_url="https://ollama.yourdomain.com/v1",
    api_key="YOUR_PRIVATE_KEY"
)

response = client.chat.completions.create(
    model="llama3.1:8b",
    messages=[
        {
            "role": "user",
            "content": "Explain why self-hosted AI can be useful."
        }
    ]
)

print(response.choices[0].message.content)

This architecture allows your application to keep its familiar OpenAI-style interface while directing requests to a model running on infrastructure you control.

Optional: Add a Chat Interface With Open WebUI

Ollama itself is primarily a model runtime and API. If you want a browser experience closer to ChatGPT, Open WebUI is a popular self-hosted interface that can connect to Ollama.

With Open WebUI you can add features such as conversation history, account management, model switching and a graphical interface for users who do not want to interact with the command line.

Useful official resources

Always verify installation commands against current official documentation because both projects evolve rapidly.

Ollama Official Site Open WebUI

Common Ollama VPS Mistakes to Avoid

1. Exposing port 11434 directly

Keep the raw Ollama API bound locally and control external access using a properly secured reverse proxy or SSH tunnel.

2. Buying too little memory

A model that nearly fills your server’s RAM leaves little room for context, additional processes or another loaded model.

3. Expecting CPU performance to feel like a GPU

CPU inference may be acceptable for asynchronous workflows but can feel painfully slow for an interactive AI assistant.

4. Ignoring concurrency

A server that feels fast with one request may perform very differently when five, ten or twenty users submit requests simultaneously.

5. Using enormous context windows without checking VRAM

Context caching consumes memory. Large context windows combined with parallel requests can produce out-of-memory failures even when the base model fits comfortably.

6. Assuming self-hosting is always cheaper

Calculate utilization. An expensive GPU that spends most of its day idle can cost substantially more per token than an API.

Is Self-Hosting Ollama Worth It?

For the right workload, absolutely. Ollama provides one of the easiest entry points into running open language models on your own infrastructure.

The strongest reasons to self-host are usually control, privacy, predictable infrastructure and the freedom to build around models without depending entirely on an external AI provider.

The tradeoff is that you become responsible for the server. Security, updates, monitoring, performance tuning, backups and capacity planning are now your job.

Simple recommendation: use a small CPU instance for learning and background AI automation. If you need fast interactive responses or several simultaneous users, move to GPU infrastructure.

Frequently Asked Questions

Can I run Ollama on a VPS?

Yes. Ollama can run on a Linux VPS as long as the server has enough RAM or GPU VRAM for the model you want to use.

Can Ollama run without a GPU?

Yes. Ollama supports CPU inference. Small models can work well enough for private automation and testing, although generation is usually much slower than GPU inference.

How much RAM do I need for Ollama?

It depends on the model and quantization. Small models may fit on an 8 GB VPS, while larger models can require 16 GB, 32 GB or substantially more memory.

What port does Ollama use?

Ollama commonly listens on port 11434. For an internet-facing deployment, avoid exposing this port directly and put a secured HTTPS proxy in front of the service.

Is Ollama API compatible with OpenAI clients?

Ollama provides OpenAI-compatible endpoints that allow many existing OpenAI client libraries and applications to connect by changing their base URL.

Is Ollama completely free?

Ollama itself is open-source software. You still pay for any VPS, GPU server, electricity, bandwidth or other infrastructure required to run your models.

Is self-hosted AI private?

It can provide significantly more infrastructure control, because inference takes place on your server. Privacy still depends on how you secure the server, applications, logs and network access.

Should I use Ollama or a commercial AI API?

Use an API when simplicity, premium model quality and pay-as-you-go economics matter most. Consider Ollama when private processing, infrastructure ownership and open models are central to the project.

Recommended Resources

Resource Use
Ollama Official model runtime and documentation
Ollama Model Library Browse available models
Caddy HTTPS reverse proxy
Open WebUI Optional browser-based AI interface
LearnWithHasan benchmark guide Reference benchmark methodology and measurements
VS

About Vanel Sylvestre

Vanel Sylvestre writes about online business, artificial intelligence, self-hosting, marketing tools and practical technologies that entrepreneurs can use to build and grow online businesses.

Disclosure: Some links on this page may be affiliate links. If you purchase a product or service through an affiliate link, this website may receive a commission at no additional cost to you. Server pricing, software versions and model performance change frequently, so verify current specifications before purchasing infrastructure.

Vanel Sylvestre

I am Vanel Sylvestre , welcome to my world, i am a real estate investor, business owner and also i am an affiliate marketer with over 10 years of experience in online marketing i have been making thousands Online Using Online Marketing Tools. In This blog We share some online marketing tools that can help you grow your business, if this is something you are interested in, one more time welcome to my world.

Leave a Reply