BestLLMfor Your hardware. Your LLM. Your call.
◆ The kits◆ Kits APIOpen data Find my LLM
Updated September 2026

Running Ollama as a Service

Verdict (September 2026): On a desktop or workstation you rarely type ollama serve yourself — the installer already runs it as a background service listening on 127.0.0.1:11434. You only touch it directly when you want to change the bind address (to reach the API from another machine), run a manual foreground instance for debugging, or override environment variables like keep-alive. Bind to your LAN only behind a firewall or reverse proxy, never straight onto the open internet, because the API is unauthenticated by default.

What `ollama serve` does and why port 11434

ollama serve launches the Ollama HTTP server — the long-running process that loads models into VRAM and answers requests. Every CLI command you run (ollama run, ollama pull, ollama list) is a thin client that talks to this server over HTTP. If the server is already running, a second ollama serve just fails with an "address already in use" error, which is the usual sign the background service has it covered.

By default the server listens on 127.0.0.1:11434. That loopback address means it accepts connections only from the same machine — a deliberate, safe default. Port 11434 is the fixed Ollama convention and is what every SDK, IDE plugin, and tool assumes unless you tell it otherwise. You can confirm the server is alive by requesting its root path, which returns Ollama is running, or by hitting the /api/tags endpoint to list installed models. If you are new to the tool, our what is Ollama guide covers the client/server split in more depth, and the official API docs document every endpoint.

Exposing Ollama on your LAN safely

The single most important variable is OLLAMA_HOST. Setting it to 0.0.0.0:11434 tells the server to accept connections on every network interface, which is what lets a laptop, a phone, or a second workstation call your GPU box. The catch: the Ollama API has no built-in authentication. Anyone who can reach the port can pull models, run inference on your hardware, and read your model list. Treat 0.0.0.0 as "visible to the whole network," not "visible to me."

Safe patterns, in rough order of preference:

  • Firewall the port. Bind to 0.0.0.0 but restrict 11434 to trusted source IPs or subnets with your OS firewall (ufw, firewalld, pf, or Windows Defender Firewall).
  • Reverse proxy with auth. Keep Ollama on loopback and put Nginx or Caddy in front to add TLS plus basic-auth or a token header. This is the right move if you need access beyond a trusted LAN.
  • SSH tunnel. For one-off remote access, forward 11434 over SSH and leave the bind address on loopback. Nothing new is exposed.

If you serve a browser-based client, you may also need OLLAMA_ORIGINS to allow specific cross-origin requests. Never open 11434 to the public internet via port-forwarding on your router — an unauthenticated inference server is an open invitation to abuse your electricity and your GPU.

Autostart: systemd, launchd, and Windows

You generally do not want to babysit a terminal window. Each platform has a native way to keep the server running and start it at boot:

PlatformService managerHow to configure env vars
Linux (install script)systemd unit ollama.servicesystemctl edit ollama to add an override with Environment= lines, then systemctl daemon-reload and restart
macOSlaunchd (via the menu-bar app)Set variables with launchctl setenv, or configure them in the app, then restart Ollama
WindowsBackground app / startup entrySet user environment variables in system Settings, then quit and relaunch Ollama

On Linux, the install script creates and enables ollama.service for you, so the server already survives reboots. The correct way to inject something like OLLAMA_HOST or OLLAMA_KEEP_ALIVE is a drop-in override — editing the shipped unit file directly gets overwritten on upgrade. After any change, systemctl status ollama and journalctl -u ollama tell you whether it came back up cleanly. Exact command syntax drifts between releases, so check the Ollama FAQ for the current recipe rather than trusting a stale snippet.

Keep-alive: how long models stay in VRAM

Loading a model into VRAM takes seconds; unloading and reloading it on every request is wasteful. OLLAMA_KEEP_ALIVE (or the keep_alive field in an API call) controls how long an idle model stays resident before it is evicted to free memory.

ValueBehavior
Default (5m)Model stays loaded 5 minutes after the last request
0Unload immediately after the response — frees VRAM fastest
-1Keep loaded indefinitely until manually stopped
30m, 24hAny Go-style duration you specify

Pick based on your workload and how much VRAM you have to spare. A shared coding assistant benefits from -1 or a long window so the first token is always fast. On an 8 GB card where you juggle several models, 0 or a short keep-alive avoids out-of-memory errors when a second model tries to load. Size the model itself before worrying about residency: use the VRAM calculator and, as a rule of thumb, a Q4_K_M quant needs roughly 0.58 GB per billion parameters plus about 20% for KV cache and overhead at 8K context. Our best Ollama models shortlist flags which quants fit common cards.

Verifying, troubleshooting, and where to go next

When something misbehaves, work from the outside in. First confirm the server is up: request the root URL and expect Ollama is running. If it refuses the connection, the service isn't started or is bound to a different address — check OLLAMA_HOST. If a remote client times out but local works, it's almost always a firewall rule or a bind still pinned to loopback. If inference is slow to start every time, your keep-alive is too short or the model is spilling to CPU because it doesn't fit in VRAM.

For provider comparisons, LM Studio vs Ollama and Ollama vs llama.cpp cover the trade-offs if you're deciding what to run the service on. The canonical reference for flags and exact CLI syntax is the Ollama GitHub repository — because command names and defaults do change between releases, treat any specific tag or flag you read elsewhere as something to verify there before you rely on it in a startup script.

Frequently asked questions

What port does ollama serve use by default?

Ollama listens on port 11434 bound to 127.0.0.1, so only the local machine can reach it. This port is a fixed convention that every Ollama client and SDK assumes. Change the bind address with the OLLAMA_HOST environment variable if you need network access.

How do I expose Ollama to other computers on my network?

Set OLLAMA_HOST to 0.0.0.0:11434 and restart the service so it listens on all interfaces. Because the API has no authentication, restrict access with a firewall rule, an SSH tunnel, or a reverse proxy that adds a password. Never forward the port to the public internet.

Do I need to run ollama serve manually?

Usually no. The desktop installers register Ollama as a background service (systemd on Linux, launchd on macOS, a startup app on Windows) that starts at boot. Run ollama serve by hand only for debugging or when no managed service exists.

How do I stop Ollama from unloading models between requests?

Set OLLAMA_KEEP_ALIVE to -1 to keep a model resident in VRAM indefinitely, or a duration like 30m for a longer idle window. The default is 5 minutes. Use 0 to unload immediately after each response when VRAM is tight.


By Mohamed Meguedmi — independent comparator of locally-runnable LLMs, benchmarked on a real RTX 5070 Ti (data CC BY 4.0). See the local LLM leaderboard and the best Ollama models.