Cloud Explainers

Ollama: Full Tutorial for Beginners

Local LLMs (Ollama)15 min video

Ollama for beginners, start to finish on a real laptop with no graphics card: install it on Linux (and where to get it for Mac and Windows), pull and run Llama 3.2, chat, read the speed with --verbose, see what is loaded with ollama ps, why an 8 GB model crashes with only 'EOF' (the out-of-memory killer) and how to pick a model that fits your memory, build your own model with a Modelfile, the long-input trap (a log cut short by the 4096-token default context) and the num_ctx fix, the REST API on port 11434 (/api/generate, /api/chat and its history, Python, the OpenAI-compatible /v1 endpoint), and letting another computer use it safely with OLLAMA_HOST.

Ollama: Full Tutorial for Beginners, the full picture: diagram of You, ollama command, Your app, Ollama server, ollama.com, Model files, Memory + CPU, Other computers, all on your computer
The whole picture, from the video's recap.

AI on your own computer

Here's how to run AI models on your own computer with Ollama. Same laptop, two models: one crashes, one answers.

Same laptop, two models: comparison table of gemma4:12b (8.0 GB) vs llama3.2 (2.0 GB), ollama run, What happened, Fits in memory?, Result

No account, no API key, and nothing leaves your machine. By the end, you'll know why the big one failed, and how to pick, build and call one that works.

dev@laptop: your computer
ollama run gemma4:12b "Hello!"Error: Post "http://127.0.0.1:11434/api/generate": EOF
dev@laptop: your computer
ollama run llama3.2 "In one sentence, what is a log file?"A log file is a record of events, activities, or errors that occur during a software application, system operation, or process execution, typically in a text or digital format.

What Ollama is

Think of a music app. A store with millions of songs. You download the ones you like, they stay on your phone, and you press play, even with no signal.

Ollama works the same way with AI models. The store is ollama.com. pull downloads a model. list shows what's on your computer. And run presses play.

Four words you'll type all the time: cards of ollama.com, ollama pull, ollama list, ollama run

Here's the whole system. Ollama is a server: a program that runs in the background on your computer, and waits for questions. You talk to it with the ollama command, or from your own app. It downloads a model from ollama.com once, keeps the files on your disk, and loads them into memory to answer. A model is one big file of numbers, trained to predict the next word. The first one we'll use, Meta's Llama 3.2, came out in September 2024, in sizes made for phones and laptops. Apart from that one download, everything here runs on your computer.

Install it

Here's the computer for this tutorial: a laptop running Ubuntu Linux, with no graphics card. free dash h shows its memory: 7.7 gigabytes in total, 7.1 available. Remember that number: in this video, memory decides almost everything. And Ollama isn't installed yet. The lab files and every command are linked in the description, so you can follow along.

dev@laptop: your computer
free -h               total        used        free      shared  buff/cache   available
Mem:           7.7Gi       650Mi       6.9Gi       224Ki       377Mi       7.1Gi
Swap:          1.0Gi        23Mi       1.0Gi
dev@laptop: your computer
ollama --versionbash: ollama: command not found

On a Mac or on Windows, you download the app from ollama.com. On Linux, it's one command. curl downloads Ollama's install script, and the pipe hands it to sh, the shell, to run. In 46 seconds, it installs the ollama program, creates a user called ollama to run it, and sets it up as a service: a program Linux starts at boot and keeps running. You'll see one warning: it found no NVIDIA or AMD graphics card. That's expected on this laptop, so Ollama will use the CPU instead.

dev@laptop: your computer
curl -fsSL https://ollama.com/install.sh | sh>>> Installing ollama to /usr/local
>>> Downloading ollama-linux-arm64.tar.zst
>>> Creating ollama user...
>>> Adding ollama user to video group...
>>> Adding current user to ollama group...
>>> Creating ollama systemd service...
>>> Enabling and starting ollama service...
Created symlink /etc/systemd/system/default.target.wants/ollama.service → /etc/systemd/system/ollama.service.
WARNING: Unable to detect NVIDIA/AMD GPU. Install lspci or lshw to automatically detect and install GPU dependencies.

Check it. ollama dash dash version: 0.40.19. systemctl status: enabled, so it starts at boot, and active, running now. The server has an address: localhost, which means this computer, and port 11434: a port is a numbered door that one program listens at. ss lists those doors: 127.0.0.1, port 11434. 127.0.0.1 is localhost as a number. And curl, a tool that sends web requests, gets a plain answer: Ollama is running.

dev@laptop: your computer
ollama --versionollama version is 0.40.19
dev@laptop: your computer
systemctl status ollama --no-pager -n 0● ollama.service - Ollama Service
     Loaded: loaded (/etc/systemd/system/ollama.service; enabled; preset: enabled)
     Active: active (running) since Wed 2026-12-02 22:29:22 UTC; 11s ago
   Main PID: 228 (ollama)
      Tasks: 12 (limit: 9563)
     Memory: 15.9M (peak: 35.9M)
        CPU: 65ms
     CGroup: /system.slice/ollama.service
             └─228 /usr/local/bin/ollama serve
dev@laptop: your computer
ss -ltn 'sport = :11434'State                                                        Recv-Q                                                       Send-Q                                                                                                             Local Address:Port                                                                                                               Peer Address:Port                                                       Process
LISTEN                                                       0                                                            4096                                                                                                                   127.0.0.1:11434                                                                                                                   0.0.0.0:*
dev@laptop: your computer
curl localhost:11434; echoOllama is running

Your first model

ollama list shows the models here: none yet. ollama pull llama3.2 downloads Llama 3.2 from the library. Guess first: this model has 3.2 billion parameters, the numbers it learned in training. How big is the download? Two gigabytes. It took 29 seconds here. And before it says success, Ollama checks the file's fingerprint, the sha256 digest, so you know nothing got corrupted on the way.

dev@laptop: your computer
ollama listNAME    ID    SIZE    MODIFIED
dev@laptop: your computer
ollama pull llama3.2pulling manifest
pulling dde5aa3fc5ff: 100% ▕█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ ▏ 2.0 GB/2.0 GB   93 MB/s      0s
pulling 34bb5ab01051: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏  561 B
verifying sha256 digest
writing manifest
success

But why only two gigabytes? At 16 bits, two bytes each, 3.2 billion numbers fill 6.4 gigabytes. At 8 bits, one byte each: 3.2. Ollama's models are rounded further, to about five bits a number, on average. That's called quantization. The answers get a little less precise, and the model fits on an ordinary laptop.

3.2B parameters, three ways to store them: chart of 16 bits = 2 bytes each (worked out): 6.4 GB, 8 bits = 1 byte each (worked out): 3.2 GB, Q4_K_M, as pulled: 2 GB, 16 bits = 2 bytes a number

ollama show prints the model's card. Parameters: 3.2B, for 3.2 billion. Quantization: Q4_K_M: mostly four bits a number, with a few parts kept at more. That's where the average of about five comes from. And context length: 131,072. That's how much text the model can read at once, counted in tokens: pieces of text, often a short word, sometimes part of a longer one. Keep that number in mind. It comes back, with a catch.

dev@laptop: your computer
ollama show llama3.2  Model
    architecture        llama
    parameters          3.2B
    context length      131072
    embedding length    3072
    quantization        Q4_K_M
    template source     go_template

  Capabilities
    completion
    tools

  Parameters
    stop    "<|start_header_id|>"
    stop    "<|end_header_id|>"
    stop    "<|eot_id|>"

  License
    LLAMA 3.2 COMMUNITY LICENSE AGREEMENT
    Llama 3.2 Version Release Date: September 25, 2024
    ...

Ask it something

Now ask it something: ollama run, the model, and your question in quotes. The answer arrives word by word, in about 8 seconds, loading included. Nothing left this laptop: the model and the answer are both right here.

Leave the question off, and you get a chat. Three arrows mean it's waiting for you. Tell it your web server is called web-7. Then ask what it's called. It remembers, because the ollama command sends the whole chat again with every message. Type slash bye to end the chat.

dev@laptop: your computer
ollama run llama3.2>>> My web server is called web-7. Reply with one word: OK.
OK.
>>> What is my web server called?
web-7.
>>> /bye

Ask the same question twice. Write a one-line motto for a web server. Guess first: will you get the same answer both times? No. Two different answers. A model picks each next word with a little randomness, and a setting called temperature sets how much. That's good for ideas, and bad when you want the same answer every time. You'll fix that in your own model soon.

dev@laptop: your computer
ollama run llama3.2 "Write a one-line motto for a web server.""Reliable, resilient, and responsive: Serving the web, one connection at a time."
dev@laptop: your computer
ollama run llama3.2 "Write a one-line motto for a web server.""Serving stability, securing reliability, and scaling with precision."

How fast is it? Add dash dash verbose. 49 tokens in about 2.4 seconds: an eval rate of 20.10 tokens a second, on the CPU alone. That's how fast it writes. The prompt eval rate, 24.06, is how fast it reads your words.

dev@laptop: your computer
ollama run llama3.2 --verbose "Explain a 404 error in one sentence."A 404 error, short for "Not Found," is a web page error that occurs when a user attempts to access a URL that does not exist or has been removed, resulting in a message indicating that the requested page cannot be found.

total duration:       3.068797668s
load duration:        1.253333ms
prompt eval count:    35 token(s)
prompt eval cached:   20 token(s)
prompt eval duration: 623.497ms
prompt eval rate:     24.06 tokens/s
eval count:           49 token(s)
eval duration:        2.437439s
eval rate:            20.10 tokens/s

ollama ps shows what's loaded right now. Guess first: the file on disk is two gigabytes. How much memory does it take once it's loaded? More. 2.9 gigabytes. The extra is working space for the context. 100 percent CPU, which means the whole model sits in the computer's ordinary memory, not on a graphics card. Context: 4,096 tokens, not the 131,072 from the card. That's the catch, and it bites later. Ollama keeps a model loaded for five minutes after you use it. ollama stop frees it now.

dev@laptop: your computer
ollama psNAME               ID              SIZE      PROCESSOR    CONTEXT    RUNNER      UNTIL
llama3.2:latest    a80c4f17acd5    2.9 GB    100% CPU     4096       llamacpp    4 minutes from now
dev@laptop: your computer
ollama stop llama3.2; ollama psNAME    ID    SIZE    PROCESSOR    CONTEXT    RUNNER    UNTIL

A smaller size: ollama pull llama3.2 colon 1b, 1.3 gigabytes. The same question with dash dash verbose: 39.78 tokens a second, against 20.10 for the 3B, and ps shows 1.8 gigabytes of memory. Smaller models are faster and lighter, and their answers are usually less careful. We'll keep the 3B, so ollama rm deletes the 1B.

dev@laptop: your computer
ollama pull llama3.2:1bpulling manifest
pulling 74701a8c35f6: 100% ▕████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████  ▏ 1.3 GB/1.3 GB  106 MB/s      0s
pulling 966de95ca8a6: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ 1.4 KB
pulling fcc5a6bec9da: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ 7.7 KB
pulling a70ff7e570d9: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏ 6.0 KB
pulling 4f659a1e86d7: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏  485 B
verifying sha256 digest
writing manifest
success
dev@laptop: your computer
ollama run llama3.2:1b --verbose "Explain a 404 error in one sentence."A 404 error is a type of internet error that occurs when a webpage or resource on a website cannot be found, indicating that the requested URL is not accessible or has been removed.

total duration:       2.410928833s
load duration:        1.295171625s
prompt eval count:    35 token(s)
prompt eval duration: 159.178ms
prompt eval rate:     219.88 tokens/s
eval count:           38 token(s)
eval duration:        955.142ms
eval rate:            39.78 tokens/s
dev@laptop: your computer
ollama psNAME           ID              SIZE      PROCESSOR    CONTEXT    RUNNER      UNTIL
llama3.2:1b    baf6a787fdff    1.8 GB    100% CPU     4096       llamacpp    4 minutes from now
dev@laptop: your computer
ollama stop llama3.2:1b; ollama rm llama3.2:1bdeleted 'llama3.2:1b'

A model too big

Bigger models usually give better answers. So try one: Google's Gemma 4, the 12B size. It's 8.0 gigabytes, and the download takes 90 seconds. ollama list now shows both: 8.0 and 2.0.

dev@laptop: your computer
ollama pull gemma4:12bpulling manifest
pulling 0cb0cd0a5c49:  98% ▕████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████          ▏ 171 MB/175 MB   53 MB/s      0s
pulling bb722270d543: 100% ▕█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ ▏ 7.4 GB/7.4 GB  105 MB/s      0s
pulling 7008a656050b: 100% ▕████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████  ▏ 463 MB/465 MB  108 MB/s      0s
pulling e5ca99f91896: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏  242 B
verifying sha256 digest
writing manifest
success
dev@laptop: your computer
ollama listNAME               ID              SIZE      MODIFIED
gemma4:12b         6114515d63c1    8.0 GB    5 seconds ago
llama3.2:latest    a80c4f17acd5    2.0 GB    3 minutes ago

Now run it. After 14 seconds: Error, EOF. EOF means end of file: the server hung up in the middle. That tells you nothing. The service's log does. journalctl reads a service's log on Linux, and grep keeps the lines that mention OOM, short for out of memory. And there it is: killed by the OOM killer. Linux ran out of memory, and stopped the biggest program to save itself. Then systemd, Linux's service manager, started Ollama again, by itself.

dev@laptop: your computer
journalctl -u ollama --no-pager | grep -i 'oom'Dec 02 22:33:54 laptop systemd[1]: ollama.service: A process of this unit has been killed by the OOM killer.
Dec 02 22:33:54 laptop systemd[1]: ollama.service: Failed with result 'oom-kill'.

So here's the rule. Llama 3.2 takes 2.0 gigabytes on disk, and 2.9 once it's loaded: the file, plus working space. Gemma 12B is 8.0 on disk, before any working space: nearly all of this laptop's memory. So pick a file well under your free memory. To see yours: free dash h, or your system monitor.

Memory a model needs: file + working space: chart of llama3.2 on disk: 2 GB, llama3.2 loaded: 2.9 GB, gemma4:12b on disk: 8 GB, Memory needed: the file + working space

Gemma 4 also comes smaller: the E2B size, 4.6 gigabytes, well under this laptop's memory. Run it, and it answers, thinking out loud first. Then ollama rm deletes the 12B you can't use.

dev@laptop: your computer
ollama pull gemma4:e2bpulling manifest
pulling 6dd7ac24fe13: 100% ▕█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ ▏ 3.5 GB/3.5 GB   90 MB/s      0s
pulling 7ba3bbacdf1b: 100% ▕█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████ ▏ 986 MB/986 MB   79 MB/s      0s
pulling dd57b3b7308f: 100% ▕████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████  ▏  97 MB/ 97 MB   81 MB/s      0s
pulling b507b9c2f6ca: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏   13 B
pulling 2365fbb6d97b: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏   64 B
pulling 3ff8a734c316: 100% ▕██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏  241 B
verifying sha256 digest
writing manifest
success
dev@laptop: your computer
ollama run gemma4:e2b "Hello!"Thinking...
Thinking Process:

1.  **Analyze the input:** The input is "Hello!".
2.  **Determine the intent:** This is a standard greeting.
3.  **Formulate an appropriate response:** A friendly, welcoming, and conversational response is expected.
4.  **Standard response components:**
    *   A reciprocal greeting (e.g., Hello, Hi).
    *   An inquiry about the user's well-being or purpose (e.g., How can I help?).
5.  **Draft the response:** Keep it concise and open-ended.

*(Self-Correction/Refinement: Keep it simple and positive.)*

6.  **Final Output Generation.**
...done thinking.

Hello! How can I help you today?
dev@laptop: your computer
ollama rm gemma4:12bdeleted 'gemma4:12b'

Your own model: a Modelfile

Remember the two different mottos? For reading logs, you want the same answer every time, and you don't want to repeat your instructions in every question. A Modelfile fixes both: a text file with a few lines. FROM picks the base model. PARAMETER temperature 0 takes the randomness out, so answers stay steady. SYSTEM is an instruction it follows in every chat: read server logs, and answer in one short sentence.

dev@laptop: your computer
cat ModelfileFROM llama3.2
PARAMETER temperature 0
SYSTEM """You read server logs. Answer in one short sentence."""

ollama create builds it, under the name logbot. A model in Ollama is a set of layers: the numbers, the template, the license, the settings. Read the lines: using existing layer. It reuses Llama's layers, and adds two new ones: your settings and your system message. du, which measures a folder's size, shows the models folder: 6.2 gigabytes before, 6.2 after. Almost no disk space. Hand it a real log line: one sentence back. Ask again: the same answer, word for word. That's temperature 0.

dev@laptop: your computer
ollama create logbot -f Modelfilegathering model components
using existing layer sha256:dde5aa3fc5ffc17176b5e8bdc82f587b24b2678c6c66101bf7da77af9f7ccdff
using existing layer sha256:966de95ca8a62200913e3f8bfbf84c8494536f1b94b49166851e76644e966396
using existing layer sha256:fcc5a6bec9daf9b561a68827b67ab6088e1dba9d1fa2a50d7bbcc8384e0a265d
using existing layer sha256:a70ff7e570d97baaf4e62ac6e6ad9975e04caa6d900d3742d37698494479e0cd
creating new layer sha256:7acf551e24ec95218a9d3757d1b7786511c5a4d66f51478169a962577d6b946c
creating new layer sha256:989cadf17acfb5e3ce5d63c1df3bf629a1d24262e857d0098c85cb34282cfc62
writing manifest
success
dev@laptop: your computer
sudo du -sh /usr/share/ollama/.ollama/models6.2G	/usr/share/ollama/.ollama/models
dev@laptop: your computer
ollama run logbot "2026-12-02 02:14:07 ERROR backup: disk full on /var (0 bytes left), backup stopped"The backup process was interrupted due to a disk full error on the /var partition, leaving no space for further backups.
dev@laptop: your computer
ollama run logbot "2026-12-02 02:14:07 ERROR backup: disk full on /var (0 bytes left), backup stopped"The backup process was interrupted due to a disk full error on the /var partition, leaving no space for further backups.

The long-input trap

Now a real job: a log of 201 lines. The first line is the error: the backup stopped at 02:14:07. Ask logbot: at what time did the backup stop? The dollar sign and brackets paste the whole file into the question. 02:18:19. Wrong, and said with total confidence.

dev@laptop: your computer
wc -l app.log201 app.log
dev@laptop: your computer
head -3 app.log2026-12-02 02:14:07 ERROR backup: disk full on /var (0 bytes left), backup stopped
2026-12-02 02:15:00 INFO web: GET /login 200 22ms
2026-12-02 02:15:01 INFO web: GET /static/app.js 200 86ms
dev@laptop: your computer
ollama run logbot "$(cat app.log) At what time did the backup stop?"The backup stopped at 02:18:19.

The reason is in the server's log, read with journalctl as before. Truncating input prompt: your log came to 5,070 tokens, about 25 a line, and Ollama kept only 2,050 of them. It kept the end, and cut the start, where the error was, without a word on your screen.

dev@laptop: your computer
journalctl -u ollama --no-pager | grep truncating | tail -1Dec 02 22:36:11 laptop ollama[537]: time=2026-12-02T22:36:11.748Z level=WARN source=llama_server.go:350 msg="truncating input prompt" limit=2050 prompt=5070 keep=4 new=2050

And when your input won't fit, Ollama's code keeps about half the window free for the answer. So of your 5,070 tokens, only 2,050 got in: the last ones, not the error at the top.

Too long for the window: the start is cut: chart of your log: 5070 tokens, the default window: 4096 tokens, what got in: 2050 tokens, About half the window stays free for the answer

So raise it for logbot. Add one line to the Modelfile: PARAMETER num_ctx 8192. Create logbot again, ask the same question, and this time: 02:14:07. Right. It took 44 seconds to read the whole log on this CPU. The cost shows in ps: 8,192 tokens of context, and 3.5 gigabytes of memory, up from 2.9. You can also set num_ctx inside a chat, or in an API request, which is next.

dev@laptop: your computer
cat ModelfileFROM llama3.2
PARAMETER temperature 0
PARAMETER num_ctx 8192
SYSTEM """You read server logs. Answer in one short sentence."""
dev@laptop: your computer
ollama create logbot -f Modelfilegathering model components
using existing layer sha256:dde5aa3fc5ffc17176b5e8bdc82f587b24b2678c6c66101bf7da77af9f7ccdff
using existing layer sha256:966de95ca8a62200913e3f8bfbf84c8494536f1b94b49166851e76644e966396
using existing layer sha256:fcc5a6bec9daf9b561a68827b67ab6088e1dba9d1fa2a50d7bbcc8384e0a265d
using existing layer sha256:a70ff7e570d97baaf4e62ac6e6ad9975e04caa6d900d3742d37698494479e0cd
using existing layer sha256:7acf551e24ec95218a9d3757d1b7786511c5a4d66f51478169a962577d6b946c
creating new layer sha256:7523dcd37bbc33834834e14178838f2ed684fac475f85d5193fc1780ab721a31
writing manifest
success
dev@laptop: your computer
ollama run logbot "$(cat app.log) At what time did the backup stop?"The backup stopped at 02:14:07.
dev@laptop: your computer
ollama psNAME             ID              SIZE      PROCESSOR    CONTEXT    RUNNER      UNTIL
logbot:latest    4264d9514086    3.5 GB    100% CPU     8192       llamacpp    4 minutes from now

The API on port 11434

So far you typed every question by hand. To use a model from your own program, you need its API. The ollama command is only a client: it talks to the server on port 11434 over HTTP, the language of the web, and your programs can do the same. Three addresses matter: api generate, for one question; api chat, for a conversation; and v1 chat completions, for tools written for OpenAI.

Port 11434: one server, three doors: diagram of ollama command, curl, Your program, Ollama server, /api/generate, /api/chat, /v1/chat/completions

Now a question. curl sends it to api generate as JSON, a text format of names and values in curly brackets: the model, the prompt, and stream false, so the answer comes back in one piece. jq keeps three fields: the response; the eval count, 29 tokens; and the eval duration. That one is in nanoseconds, billionths of a second, so 1.18 seconds here.

dev@laptop: your computer
curl -s localhost:11434/api/generate -d '{"model": "logbot", "prompt": "What does HTTP 503 mean?", "stream": false}' | jq '{response, eval_count, eval_duration}'{
  "response": "HTTP 503 Service Unavailable indicates that the server is currently unable to handle the request due to maintenance, overload, or other temporary issues.",
  "eval_count": 29,
  "eval_duration": 1183521000
}

Now api chat, and a surprise. Tell it your server is called web-7. Then, in a second request, ask what it's called. It has no idea. In the chat earlier, the ollama command sent the history for you. Here, nothing does. So send it yourself: your first message, its reply, then the question, each marked with its role: user for you, assistant for the model. Now it answers web-7.

dev@laptop: your computer
curl -s localhost:11434/api/chat -d '{"model": "llama3.2", "messages": [{"role": "user", "content": "My web server is called web-7. Reply with one word: OK."}], "stream": false, "options": {"seed": 7}}' | jq -r .message.contentOK.
dev@laptop: your computer
curl -s localhost:11434/api/chat -d '{"model": "llama3.2", "messages": [{"role": "user", "content": "What is my web server called?"}], "stream": false, "options": {"seed": 7}}' | jq -r .message.contentI don't have any information about your specific web server. The term "web server" is a general term that can refer to any server that hosts and serves websites, web applications, or other online content.

If you're referring to your own web server, it's likely that you have a specific name or hostname for it, such as "yourwebsite.com" or "yourserver.com". If you're asking about the type of web server software or hardware you're using, I'd be happy to try and help with that information.
dev@laptop: your computer
curl -s localhost:11434/api/chat -d '{"model": "llama3.2", "messages": [{"role": "user", "content": "My web server is called web-7. Reply with one word: OK."}, {"role": "assistant", "content": "OK."}, {"role": "user", "content": "What is my web server called?"}], "stream": false, "options": {"seed": 7}}' | jq -r .message.contentweb-7.

Here's the same call from Python. requests, a popular library for web calls, posts your log and your question to logbot on api chat, and prints the reply. Run it: 02:14:07. Right. And for tools written for OpenAI's API, set the address to localhost, port 11434, slash v1. They'll want an API key: Ollama's docs say it's required but ignored, so any word works, and logbot answers.

dev@laptop: your computer
cat ask.pyimport sys
import requests

URL = "http://localhost:11434/api/chat"
log = open(sys.argv[1]).read()
question = sys.argv[2]

reply = requests.post(URL, json={
    "model": "logbot",
    "messages": [{"role": "user", "content": log + "\n" + question}],
    "stream": False,
}).json()
print(reply["message"]["content"])
dev@laptop: your computer
python3 ask.py app.log "At what time did the backup stop?"The backup stopped at 02:14:07.
dev@laptop: your computer
curl -s localhost:11434/v1/chat/completions -d '{"model": "logbot", "messages": [{"role": "user", "content": "What does HTTP 503 mean?"}]}' | jq -r '.choices[0].message.content'HTTP 503 Service Unavailable indicates that the server is currently unable to handle the request due to maintenance, overload, or other temporary issues.

From another computer

Say the model runs on your laptop, but you want to use it from your desktop. Let's try. The desktop asks the laptop's Ollama, by the laptop's name, on port 11434. Failed to connect. Remember: 127.0.0.1 listens only to its own computer.

dev@desktop: another computer
curl http://laptop:11434curl: (7) Failed to connect to laptop port 11434 after 2 ms: Couldn't connect to server

That's on purpose, and a server setting called OLLAMA_HOST changes it. On Linux, you set it with an override file: a small file that adds to the service's settings. Inside: OLLAMA_HOST equals 0.0.0.0, port 11434: every network the laptop is on. Reload systemd, restart Ollama, and ss shows it listening on every address: the star. Other server settings, like OLLAMA_CONTEXT_LENGTH, go in the same file.

dev@laptop: your computer
sudo mkdir -p /etc/systemd/system/ollama.service.d && printf '[Service]\nEnvironment="OLLAMA_HOST=0.0.0.0:11434"\n' | sudo tee /etc/systemd/system/ollama.service.d/override.conf[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"
dev@laptop: your computer
sudo systemctl daemon-reload && sudo systemctl restart ollama
dev@laptop: your computer
ss -ltn 'sport = :11434'State                                                        Recv-Q                                                       Send-Q                                                                                                             Local Address:Port                                                                                                               Peer Address:Port                                                       Process
LISTEN                                                       0                                                            4096                                                                                                                           *:11434                                                                                                                         *:*

Back on the desktop, ask again: Ollama is running. And a real answer from logbot, running on the laptop. Any program on the desktop can do the same, pointed at the laptop's name.

dev@desktop: another computer
curl http://laptop:11434; echoOllama is running
dev@desktop: another computer
curl -s http://laptop:11434/api/generate -d '{"model": "logbot", "prompt": "What does HTTP 503 mean?", "stream": false}' | jq -r .responseHTTP 503 Service Unavailable indicates that the server is currently unable to handle the request due to maintenance, overload, or other temporary issues.

One warning before you do this. Ollama has no password. Anyone who can reach that port can use your models, and the computer behind them. So open it only on a network you trust, let your firewall block the port for everyone else, and never open it to the internet. And if only this laptop needs it, keep the default: 127.0.0.1.

Port 11434 has no password: diagram of Your laptop, Your network, Firewall, The internet, your network

Recap

So: pick a model that fits your memory, run it, or call port 11434 from your code. Long input? Raise num_ctx. And no password, so open it with care.

Ollama, in four lines: cards of Fit your memory, ollama run, or port 11434, Long input?, No password

If you now have a model answering on your own computer, a like helps other beginners find this, and subscribing brings you the next full tutorial. Thanks for watching Cloud Explainers.

Sources

Demos: two containers on our own Mac standing in for your laptop and a second computer, with no graphics card. Every command, output, size and time was real. Watch the full video on YouTube.

More videos

Kubernetes10 min

Docker vs Kubernetes: What's the Difference?

HTTP & HTTPS11 min

Every HTTP Status Code You Need to Know

PostgreSQL8 min

How to Fix PostgreSQL 'Relation Does Not Exist' Errors

Git9 min

Git Merge vs Rebase: Which One Should You Use?

APIs10 min

How API Webhooks Work

LLM infrastructure9 min

How LLM Tokens Work

Docker9 min

Docker Containers vs Virtual Machines: What's the Difference?

PostgreSQL9 min

MySQL vs PostgreSQL: Which One Should You Use?

GitHub Actions15 min

GitHub Actions: Full Tutorial for Beginners

Certificates & PKI (ADCS)8 min

How to Fix Certificate Errors: 'Your Connection Is Not Private'

AWS9 min

How the Amazon Ergo AI Model Works

LLM infrastructure9 min

How to Fix LLM API Rate Limit Errors (429)

LLM infrastructure9 min

RAG vs Fine-Tuning: Which One Should You Use?

Load balancing & Nginx24 min

Nginx: Full Tutorial for Beginners

Go (Golang)5 min

Golang go func(): Starting Goroutines in 5 Minutes

Terraform23 min

Terraform: Full Tutorial for Beginners

Go (Golang)5 min

Golang Generics ([T any]) in 5 Minutes

AWS9 min

How AWS Bedrock Works

LLM infrastructure8 min

How LLM Embeddings Work

Python9 min

How to Fix Python CUDA Memory Errors in PyTorch

Go (Golang)5 min

Golang Type Assertions in 5 Minutes

LLM infrastructure10 min

CPU vs GPU for LLM Inference: What Actually Changes

Google Colab (Jupyter notebooks in the cloud)15 min

Google Colab: Full Tutorial for Beginners

AWS8 min

Amazon Bedrock vs OpenRouter: Which One Should You Use?

Go (Golang)5 min

Golang Channels (chan) in 5 Minutes

Homelab & self-hosting21 min

Tailscale: Full Tutorial for Beginners

LLM infrastructure9 min

How RAG Works

Git11 min

Every Git Setting to Change on Day One

Linux9 min

WSL vs a Linux Virtual Machine: Which One Should You Use?

PostgreSQL9 min

Every PostgreSQL Setting to Change After You Install It

Docker9 min

What Happens When You Install Docker on Ubuntu

Python8 min

How to Fix Python 'Address Already in Use' Errors

Go (Golang)5 min

Golang Interfaces and Mocks in 5 Minutes

Git7 min

How to Fix Git 'Detached HEAD' State

Linux21 min

Linux Firewall with ufw: Full Tutorial for Beginners

Go (Golang)5 min

Golang defer Statements in 5 Minutes

Auth (OAuth, JWT)9 min

How to Fix OAuth 'invalid_grant' Errors

Databases & SQL11 min

The SQL Roadmap for Beginners

Go (Golang)5 min

Golang make() for Slices and Maps in 5 Minutes

Networking7 min

How to Fix Network 'No Route to Host' Errors on Linux

Linux6 min

How to Fix Linux 'Too Many Open Files' Errors

Django (Python web framework)11 min

Every Django Concept a Beginner Needs to Know

Linux24 min

SSH on Linux: Full Tutorial for Beginners

Go (Golang)5 min

Golang for range Loops in 5 Minutes

Databases & SQL10 min

SQL Databases: SQLite vs PostgreSQL

Django (Python web framework)10 min

The Django Roadmap for Beginners

Go (Golang)5 min

Golang Structs in 5 Minutes

Caching & Redis22 min

Redis: Full Tutorial for Beginners

Go (Golang)5 min

Golang context.Context in 5 Minutes

Databases & SQL7 min

How to Fix MySQL Database Error 1045: Access Denied for User

Go (Golang)5 min

Golang Method Receivers in 5 Minutes

Python8 min

How to Fix Python SSL: CERTIFICATE_VERIFY_FAILED Errors

Django (Python web framework)9 min

How to Fix Django Static Files Not Loading in Production

OpenRouter (one API for many AI models)8 min

OpenRouter vs Direct API Keys: Which One Should You Use?

Go (Golang)5 min

Golang if err != nil Checks in 5 Minutes

Go (Golang)8 min

How to Fix Golang 'go.mod File Not Found' Errors

AI agents & MCP22 min

MCP Servers: Full Tutorial for Beginners

Go (Golang)5 min

Golang Error Return Values in 5 Minutes

Python8 min

How to Fix Python ModuleNotFoundError: No Module Named

Go (Golang)5 min

Golang Pointers in 5 Minutes

Kubernetes8 min

How to Fix a Kubernetes Pod Stuck in CrashLoopBackOff

Homelab & self-hosting9 min

How to Fix a Homelab ESXi Host Not Responding

PostgreSQL24 min

PostgreSQL: Full Tutorial for Beginners

Load balancing & Nginx9 min

How a Load Balancer Works with HAProxy

Python9 min

How Python Virtual Environments Work

Homelab & self-hosting9 min

How to Fix Cloudflare Tunnel Errors in a Homelab

APIs9 min

How to Fix API CORS Errors: No 'Access-Control-Allow-Origin'

Auth (OAuth, JWT)9 min

How Authenticator App Login Codes Work (TOTP)

Git22 min

Git and GitHub: Full Tutorial for Beginners

Homelab & self-hosting10 min

How a Homelab Hypervisor Works (VMware ESXi)

Kubernetes9 min

How to Fix Kubernetes ImagePullBackOff Errors

DNS8 min

How to Fix DNS 'Temporary Failure in Name Resolution' on Linux

AWS8 min

How to Fix AWS CLI 'Unable to Locate Credentials'

Homelab & self-hosting10 min

Proxmox vs ESXi for Your Homelab: When Each One Wins

PostgreSQL10 min

PostgreSQL UUID vs Auto Increment: Which Primary Key Should You Use?

Kubernetes21 min

Kubernetes: Full Tutorial for Beginners

Networking9 min

How TCP Sockets Work

PostgreSQL7 min

How to Fix PostgreSQL 'Could Not Connect to Server'

Claude & the Claude Developer Platform9 min

Claude Code Hooks Will Finally Make Sense After This

DevOps & CI/CD9 min

DevOps with Ansible Will Finally Make Sense After This

Networking9 min

How SNMP Network Monitoring Works

Git8 min

How to Fix GitHub 'Permission Denied (publickey)' Errors

Docker21 min

Docker: Full Tutorial for Beginners

PostgreSQL7 min

How to Fix PostgreSQL 'Password Authentication Failed'

Linux8 min

Why One Linux Server Handles More Users Than You Think

Networking7 min

How to Fix Network 'Connection Refused' Errors

DevOps & CI/CD9 min

DevOps Pipelines: Jenkins vs GitHub Actions

Linux11 min

Linux Nginx Reverse Proxy: Full Tutorial for Beginners

Networking11 min

Every Networking Term a Beginner Needs in 12 Minutes

Docker6 min

How to Fix Docker 'Permission Denied' on docker.sock

Git7 min

How to Fix Git 'Updates Were Rejected' When You Push

Linux7 min

How to Fix nginx 502 Bad Gateway Errors on Linux

Linux8 min

How to Fix Linux apt 'Could Not Get Lock' Errors (Ubuntu)

Networking9 min

How Email Works on the Internet (SMTP) in 10 Minutes

Python8 min

The Python Roadmap for Beginners

Go (Golang)21 min

Golang REST API with Gin: Full Tutorial for Beginners

Networking10 min

How a WireGuard VPN Network Works

Linux9 min

Linux Makefiles Will Finally Make Sense After This

Auth (OAuth, JWT)9 min

SAML vs OAuth vs OpenID Connect: What's the Difference?

Python7 min

How to Fix Python cron Jobs That Never Run

Linux22 min

Linux Bash Scripting: Full Tutorial for Beginners

Networking10 min

How PXE Network Boot Works

Active Directory9 min

How Active Directory Works

Linux10 min

How to Fix a Linux systemd Service That Won't Start

Linux9 min

Linux Logs: syslog vs journald

Auth (OAuth, JWT)9 min

JWT vs Session Cookies: Which One Should You Use?

Docker10 min

Docker vs Docker Compose: Which One Should You Use?

Docker9 min

How to Fix Docker Compose Containers That Can't Talk to Each Other

Django (Python web framework)22 min

Django Full Tutorial for Beginners

Linux9 min

How Linux systemd Works

Networking8 min

How to Fix 'Windows Cannot Access' Network Share Errors (SMB)

APIs10 min

REST vs gRPC: Which One Should You Use?

Certificates & PKI (ADCS)9 min

How to Fix SSL Certificate Chain Errors (Missing Intermediate)

Python9 min

Every Python Concept for Beginners in 10 Minutes

Databases & SQL9 min

Every SQL Join Type in 10 Minutes

OpenRouter (one API for many AI models)9 min

Why OpenRouter Free Models Hit Their Limit So Fast

Gemini API & Google AI Studio9 min

Why Your Gemini API Free Tier Runs Out So Fast

OpenRouter (one API for many AI models)10 min

OpenRouter Will Finally Make Sense After This

Caching & Redis10 min

How Redis Caching Works

Gemini API & Google AI Studio10 min

Gemini API vs Vertex AI: Which One Should You Use?

Gemini API & Google AI Studio8 min

How to Fix a Leaked Gemini API Key

Go (Golang)9 min

Why Golang Uses Goroutines Instead of Threads

Gemini API & Google AI Studio9 min

How to Fix Gemini API Error 429: Resource Exhausted

Claude & the Claude Developer Platform10 min

Claude Token Pricing Will Finally Make Sense After This

Python11 min

Why Python Web Scraping Returns Nothing (and the Fix)

Python10 min

Python uv vs pip: Which One Should You Use?

Python22 min

Python Automation: Full Tutorial for Beginners

Auth (OAuth, JWT)9 min

How OAuth Login Works

Gemini API & Google AI Studio10 min

Google AI Studio Will Finally Make Sense After This

Docker10 min

What Happens When You Run a Docker Container

Claude & the Claude Developer Platform8 min

How to Fix Claude Code Billing Your API Key Instead of Your Plan

Auth (OAuth, JWT)9 min

Why Passkeys Can't Be Phished Like Passwords

PowerShell10 min

PowerShell vs Bash: Which One Should You Learn?

Linux10 min

The Linux Roadmap for Beginners

Django (Python web framework)9 min

Django vs FastAPI: Which One Should You Use?

Databases & SQL10 min

Why SQLite Is the Most Used Database in the World

Databases & SQL11 min

How a NoSQL Database Like MongoDB Works

Python11 min

How to Fix Python pip error: externally-managed-environment

Databases & SQL9 min

How to Fix MySQL Too Many Connections Database Errors

Go (Golang)9 min

Golang Concurrency Will Finally Make Sense After This

AWS10 min

How Amazon S3 Works

Kubernetes10 min

How Kubernetes Works

Git10 min

How Git Works

Docker10 min

How to Fix Docker Port Already Allocated Errors

PostgreSQL10 min

How PostgreSQL Works

Git8 min

How to Fix Git Merge Conflicts

Linux9 min

How to Fix No Space Left on Device in Linux

Networking10 min

How the Internet Works

Databases & SQL9 min

SQL vs NoSQL: When Each One Wins

Auth (OAuth, JWT)8 min

How to Fix JWT Token Expired Errors (401 Unauthorized)

Claude & the Claude Developer Platform9 min

Claude API vs Claude Pro: Why Your Subscription Doesn't Include It

AI agent skills9 min

Why AI Agent Skills Beat Giant Prompts

Linux10 min

Linux Cron Jobs Will Finally Make Sense After This

Cybersecurity10 min

Security Logs Will Finally Make Sense After This

Cybersecurity8 min

How to Fix a Security Leak: An API Key Pushed to GitHub

DNS9 min

DNS Will Finally Make Sense After This

Cybersecurity9 min

Never Ignore a Security Update

Auth (OAuth, JWT)9 min

Two-Factor Authentication Will Finally Make Sense

Networking8 min

Never Expose a Database to the Internet

Cybersecurity10 min

SSH Keys vs Passwords: Which Is Safer for Security?

Linux10 min

The 5 Levels of Linux Boot: From Power On to Login

Networking12 min

The 5 Levels of Network Firewalls

Cybersecurity10 min

Password Security: Why Hackers Crack Weak Passwords

Linux9 min

Why Your Linux Server Runs Out of Memory

Networking10 min

HTTP vs HTTPS: What Actually Changes on Your Network

Linux12 min

Every Linux File Permission You Need to Know

Linux10 min

Linux Processes vs Threads: When Each One Wins

Networking11 min

The OSI Model Will Finally Make Sense After This

Git11 min

The 7 Levels of Git

Networking10 min

Every Network Troubleshooting Command You Need

Cybersecurity10 min

Hashing vs Encryption in Cybersecurity: When Each One Wins

Networking11 min

Why the Internet Ran Out of IP Addresses

Linux11 min

Linux Package Managers: apt vs Snap vs Flatpak

Python9 min

Why Python Is Slow (and When It Doesn't Matter)

Networking11 min

TCP vs UDP: When Each One Wins

Linux8 min

Stop Running Linux as Root (Do This Instead)

Linux11 min

Linux Users and Groups Will Finally Make Sense

Cybersecurity9 min

Why Phishing Beats Good Security (and How to Spot It)

Docker12 min

The 7 Levels of Docker

AI agents & MCP12 min

AI Agents Will Finally Make Sense After This

Git8 min

Stop Using git push --force (Use This Instead)

AI agent skills10 min

Agent Skills vs MCP: When Each One Wins

Networking12 min

Networking Will Finally Make Sense After This

Linux12 min

Every Linux Command You Actually Need

Cybersecurity12 min

The 7 Levels of Cybersecurity

System design12 min

Every System Design Concept You Need, in One Diagram

PostgreSQL10 min

Why PostgreSQL Ignores Your Index