Tuesday, September 15, 2026

How to setup and use a local ollama server running on a windows 11 machine, from any machine in a local area network

 ## 1. Install Ollama on the Windows 11 host

Download and install Ollama on the machine with the GPU/CPU you want to use. Pull a model and verify it locally:

```powershell

ollama pull llama3.2

ollama run llama3.2

```

Ollama normally listens only on `127.0.0.1:11434`. To permit LAN clients, configure it to listen on all interfaces with `OLLAMA_HOST=0.0.0.0:11434`. [1,2]

## 2. Configure `OLLAMA_HOST`

On the Windows host:

1. Open **Settings → System → About → Advanced system settings**.

2. Select **Environment Variables**.

3. Under **User variables**, select **New**.

4. Enter:

   - **Variable name:** `OLLAMA_HOST`

   - **Variable value:** `0.0.0.0:11434`

5. Click **OK** through all dialogs.

6. Exit Ollama completely from the system tray, then relaunch it.

If Ollama runs as a service rather than as the desktop application, restart that service after changing the variable.

`OLLAMA_ORIGINS` is only relevant to browser-based cross-origin requests; it does not make the server reachable over the network. Avoid setting it to `*` unless you specifically need browser access from arbitrary origins.

## 3. Find the Windows host’s LAN IP address

On the Windows machine, run:

```powershell

ipconfig

```

Find the **IPv4 Address** for the active Wi-Fi or Ethernet adapter. It will usually look like:

```text

192.168.1.50

```

Use this address from other machines—not `localhost`, `127.0.0.1`, or `0.0.0.0`.

It is useful to reserve this address in your router’s DHCP settings so it does not change.

## 4. Allow TCP port 11434 through Windows Firewall

Open **PowerShell as Administrator** and create a rule limited to private networks:

```powershell

New-NetFirewallRule `

  -DisplayName "Ollama LAN API" `

  -Direction Inbound `

  -Protocol TCP `

  -LocalPort 11434 `

  -Action Allow `

  -Profile Private

```

Make sure the network is classified as **Private**, not Public:

**Settings → Network & internet → Wi-Fi/Ethernet → your network → Network profile → Private**

Do not expose port 11434 through your router or enable WAN/Internet port forwarding. Ollama’s local API generally should not be placed directly on the public Internet.

## 5. Test the server locally

On the Windows host:

```powershell

curl http://127.0.0.1:11434/api/tags

```

You should receive JSON listing installed models.

You can also test using the host’s LAN address:

```powershell

curl http://192.168.1.50:11434/api/tags

```

Replace `192.168.1.50` with the actual address.

## 6. Test from another LAN computer

From another machine on the same network:

```bash

curl http://192.168.1.50:11434/api/tags

```

A successful response confirms that the remote machine can reach Ollama and see its models. Both machines must be on the same reachable LAN; guest Wi-Fi and client-isolation settings can block this connection.

## 7. Call the model remotely

Example using the Ollama REST API:

```bash

curl http://192.168.1.50:11434/api/generate \

  -H "Content-Type: application/json" \

  -d '{

    "model": "llama3.2",

    "prompt": "Explain photosynthesis in two sentences.",

    "stream": false

  }'

```

For chat requests:

```bash

curl http://192.168.1.50:11434/api/chat \

  -H "Content-Type: application/json" \

  -d '{

    "model": "llama3.2",

    "messages": [

      {

        "role": "user",

        "content": "Write a short welcome message."

      }

    ],

    "stream": false

  }'

```

## 8. Use it from applications

Many Ollama-compatible applications have a **custom endpoint**, **base URL**, or **Ollama host** setting. Enter:

```text

http://192.168.1.50:11434

```

For OpenAI-compatible applications, the base URL is often:

```text

http://192.168.1.50:11434/v1

```

The exact setting depends on the application. In Python, an Ollama-compatible client commonly uses:

```python

from ollama import Client

client = Client(host="http://192.168.1.50:11434")

response = client.chat(

    model="llama3.2",

    messages=[

        {"role": "user", "content": "Give me three project ideas."}

    ],

)

print(response["message"]["content"])

```

## Troubleshooting

- **Local test works, remote test fails:** check the Windows Firewall rule and confirm the network is set to Private.

- **`curl` connects to `127.0.0.1` but not the LAN IP:** Ollama did not restart after setting `OLLAMA_HOST`, or it is still bound only to loopback.

- **Check what is listening:**

  ```powershell

  netstat -ano | findstr :11434

  ```

  You want to see `0.0.0.0:11434` or the machine’s LAN address, rather than only `127.0.0.1:11434`.

- **Connection times out:** check that both devices are on the same subnet and that Wi-Fi client isolation is disabled.

- **Model not found:** pull the model on the Windows host:

  ```powershell

  ollama pull llama3.2

  ```

- **Using WSL2 or Docker:** networking may require additional port forwarding because WSL2 uses a virtualized network adapter; a normal Windows installation is simpler for LAN access. [1,3]

The essential configuration is:

```text

OLLAMA_HOST=0.0.0.0:11434

```

Then connect from other machines using:

```text

http://<Windows-LAN-IP>:11434

```

Read More

[1] [WSL 2] Exposing ollama via 0.0.0.0 on local network #1431 - GitHub — https://github.com/ollama/ollama/issues/1431

[2] Impossible to connect to ollama locally from another pc #6571 - GitHub — https://github.com/ollama/ollama/issues/6571

[3] [WSL2] Ollama on Windows host unreachable from Docker ... - GitHub — https://github.com/ollama/ollama/issues/14947

No comments:

Post a Comment

Mandelbrot Generation Mathworks - using Python + Nvidia GPU

 Mandelbrot Generation Mathworks - using Python + Nvidia GPU Code output during execution GPU load - RTX 3090 w/24Gb VRAM Code: Video output...