Skip to main content
Back to blog

Article

How to Self-Host Ollama and Open WebUI on Ubuntu (Step-by-Step Guide)

Install Ollama and Open WebUI on Ubuntu Linux to run private, self-hosted large language models locally without sending prompts to external cloud APIs.

Samiullah OsmanPublished 25 Nov 20263 min read
AIOllamaLinuxUbuntuSelf-Hosted
Self-hosted Ubuntu Linux mini-server running local AI with Ollama and Open WebUI

Direct answer: To run a private, ChatGPT-style AI assistant on Ubuntu Linux, install Ollama to serve open-weight models locally on port 11434, then run Open WebUI in Docker to provide a browser interface — keeping all prompts, documents, and model inference on your own hardware.


Hardware & RAM Sizing (CPU vs GPU)

Before installing, match your model size to your available RAM or GPU VRAM. Running a model that exceeds memory forces disk swapping and slows responses to a crawl.

Model Size (4-bit Quantised)Minimum RAM / VRAMTypical Use Case3B–4B (e.g., llama3.2:3b, phi3)8 GB RAM (CPU) or 4–6 GB VRAMFast notes, summaries, basic scripting7B–8B (e.g., llama3.1:8b, mistral)16 GB RAM (CPU) or 8 GB VRAMGeneral assistant, coding help, local RAG14B–32B (e.g., qwen2.5:14b)32 GB RAM or 16–24 GB VRAMStronger reasoning and technical documentation

Step 1: Install Ollama on Ubuntu

Update your Ubuntu packages and run the official Ollama Linux installer:

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

Verify that the ollama systemd service is active and listening locally:

systemctl status ollama --no-pager
ollama --version

Pull and test a lightweight model in the terminal:

ollama run llama3.2:3b "Explain the difference between TCP and UDP in two sentences."

Step 2: Install Docker & Launch Open WebUI

If Docker is not yet installed on your Ubuntu host, install the official Docker engine (see Ubuntu Server & Docker docs), then launch Open WebUI connected to your local Ollama instance:

docker run -d \
  --name open-webui \
  --network=host \
  -v open-webui:/app/backend/data \
  -e OLLAMA_BASE_URL=http://127.0.0.1:11434 \
  --restart always \
  ghcr.io/open-webui/open-webui:main

Using --network=host on a single Ubuntu machine lets Open WebUI reach Ollama at http://127.0.0.1:11434 without exposing Ollama directly to your wider network. Open your browser and visit http://<your-ubuntu-ip>:8080 to create your first local admin account.


Step 3: Lock Down Your Firewall (UFW)

Never leave unauthenticated AI endpoints open to the public internet. On Ubuntu, configure UFW to allow only SSH and your chosen interface port (or put Open WebUI behind an HTTPS reverse proxy such as Nginx or Caddy):

sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 22/tcp
sudo ufw allow from 192.168.1.0/24 to any port 8080 proto tcp
sudo ufw enable
sudo ufw status

If you are publishing Open WebUI on a domain behind HTTPS, verify your open ports with our Port Checker and inspect your TLS certificate with our SSL Certificate Checker. If you use Docker Compose, validate your configuration syntax first with the YAML Validator.


Next Steps: From Local Chat to RAG & AI Agents

Once Ollama and Open WebUI are running smoothly, you can connect local documents via Retrieval-Augmented Generation (RAG) and build private AI workflows.

Frequently Asked Questions

Do I need an expensive NVIDIA GPU to run Ollama on Ubuntu?
No. Smaller quantised models such as 3B–8B parameter models run on modern multi-core CPUs with 16 GB of RAM. A dedicated GPU with 8–24 GB VRAM simply speeds up token generation significantly.
Does self-hosting Ollama keep my prompts completely private?
Yes. Once you download a model's weights locally, inference runs entirely on your own Ubuntu machine or server with no prompts sent to third-party AI APIs.
What port does Ollama listen on by default?
Ollama listens on TCP port 11434 bound to localhost (127.0.0.1) by default, which prevents direct external access until you explicitly configure a reverse proxy or firewall rule.
Why pair Ollama with Open WebUI?
Ollama provides the local model runtime and REST API, while Open WebUI adds a clean browser chat interface, conversation history, user accounts, and document upload (RAG) features.
Can I learn this live with an instructor?
Yes. Start with our free 2-hour Host AI From Zero workshop, or move onto our Advanced Self-Hosted AI System course covering RAG pipelines and AI agents.
Samiullah Osman

Written & reviewed by

Samiullah Osman

Founder & Lead Networking Instructor · CCNP · MSc Computer Network Administration & Management

Founder of Binary Tech Institute with over 8 years of experience in computer networking and IT infrastructure, leading live mentor-led cohorts in London and online across the UK.

Ready to learn with a mentor?

Turn what you just read into hands-on skill with a live Binary Tech cohort.

WhatsAppContact us