OD OllamaDoctor
ADMINISTRATION GUIDE · SYSTEM AUTOMATION

How to Run Ollama as a Windows Service (Headless Boot)

By Systems Administration Team Updated: October 30, 2026 Windows Task Scheduler NSSM Service Unattended Boot Read Time: 10 min

By default, the Ollama Windows installer sets up Ollama to launch as an interactive application in your taskbar system tray when a specific user logs into the desktop. However, if your Windows PC functions as a home server, workstation, or remote AI host that reboots after Windows Updates, Ollama will stay offline until someone physically logs in. Here is how to configure Ollama as an unattended, headless Windows background service.

Method 1: Windows Task Scheduler (Native, Zero Downloads)

The simplest way to start Ollama automatically when your computer powers on—before any user logs in—is through native Windows Task Scheduler.

Step 1: Open PowerShell as Administrator

Right-click the Windows Start Button and select Terminal (Admin) or PowerShell (Admin).

Step 2: Create the Scheduled Task via PowerShell

Run the following script to create an automatic boot task with highest privileges:

$action = New-ScheduledTaskAction `
  -Execute "$env:LOCALAPPDATA\Programs\Ollama\ollama.exe" `
  -Argument "serve"

$trigger = New-ScheduledTaskTrigger -AtStartup

$principal = New-ScheduledTaskPrincipal `
  -UserId "$env:USERDOMAIN\$env:USERNAME" `
  -LogonType S4U `
  -RunLevel Highest

$settings = New-ScheduledTaskSettingsSet `
  -AllowStartIfOnBatteries `
  -DontStopIfGoingOnBatteries `
  -RestartCount 3 `
  -RestartInterval (New-TimeSpan -Minutes 1) `
  -ExecutionTimeLimit 0

Register-ScheduledTask `
  -TaskName "OllamaBackgroundService" `
  -Action $action `
  -Trigger $trigger `
  -Principal $principal `
  -Settings $settings `
  -Description "Starts Ollama API Server automatically on Windows boot."
Why the -UserId matters: By binding the task to your existing user account, Ollama automatically retains access to all models stored in your C:\Users\<User>\.ollama\models directory and uses your existing environment variables!

Method 2: True Windows NT Service via NSSM (Enterprise Grade)

If you require true Windows Service management (with services.msc controls, automatic crash recovery, Windows Event Log integration, and standard sc start / sc stop commands), use the Non-Sucking Service Manager (NSSM).

Step 1: Install NSSM via Winget

winget install NSSM.NSSM

Step 2: Install the Ollama Service

# Install Ollama as a Windows service:
nssm install OllamaService "$env:LOCALAPPDATA\Programs\Ollama\ollama.exe" "serve"

# Configure standard logging:
nssm set OllamaService AppStdout "$env:LOCALAPPDATA\Ollama\service_out.log"
nssm set OllamaService AppStderr "$env:LOCALAPPDATA\Ollama\service_err.log"

# Set automatic startup:
nssm set OllamaService Start SERVICE_AUTO_START

# Start the service immediately:
nssm start OllamaService

Step 3: Disable the System Tray Duplicate

Because Ollama is now running headlessly in the background on port 11434, you should disable the duplicate system tray application from launching upon user desktop login:

  1. Press Ctrl + Shift + Esc to open Task Manager.
  2. Click on the Startup apps tab.
  3. Find Ollama in the list, right-click it, and select Disable.

Step 4: Verify Service Health Upon Reboot

Restart your Windows PC. Without logging in, send an HTTP ping from another device or test after login:

Invoke-RestMethod -Uri "http://127.0.0.1:11434/api/version"

If it returns @{version=0.5.x} immediately, your headless server configuration is complete!

Frequently Asked Questions

Will running Ollama as a service prevent GPU acceleration?

No. On Windows 10 and 11, background services running under interactive user credentials or SYSTEM retain full access to DirectX and NVIDIA WDDM display drivers, allowing full CUDA GPU offloading.

How do I uninstall the scheduled task or NSSM service?

To remove the Scheduled Task: Unregister-ScheduledTask -TaskName "OllamaBackgroundService" -Confirm:$false. To remove the NSSM service: nssm stop OllamaService; nssm remove OllamaService confirm.

← LAN Remote Access Guide Install Open WebUI on Windows →
Advertisement