Won't start or won't see your GPUWindowsLinuxmacOSLast updated November 6, 2026

Ollama "connection refused" — API not reachable, ports & fixes

Something else on my network can't reach Ollama

Written by Jakub Rusinowski

The error

curl: (7) Failed to connect to localhost port 11434: Connection refused
Which one is it?
If you seeThe cause isGo to
curl http://localhost:11434 is refused on the machine running OllamaNothing is listening: the server is not runningFix 1: confirm something is listening
It works on the server but not from another deviceOllama is bound to 127.0.0.1Fix 2: bind to 0.0.0.0
It fails only from inside a containerlocalhost there is the container itselfFix 3: use host.docker.internal
ollama serve exits with address already in useAnother process, often a second Ollama, holds the portFix 5: find the squatter or move Ollama
Remote connections time out instead of being refusedA firewall is dropping the packetsFix 6: allow the port through the firewall

When you see it

Your app, script, or UI can't reach the Ollama API (or LM Studio's server on port 1234). curl fails with "connection refused", Open WebUI shows no models, VS Code extensions report the server is unreachable, or a phone/laptop on your network can't connect while the host machine itself can. The model runs fine when you chat in the terminal — only the API connection is broken.

  • Open WebUI, running in Docker, shows no models although Ollama works in a terminal.
  • A phone or a second PC on your network tries to reach the server by its IP address.
  • The Ollama tray app was quit, or the Linux service stopped after an update.
  • A second copy of Ollama, started with ollama serve, fails because the desktop app already holds the port.
  • A client inside WSL2 tries to reach Ollama running on Windows, or the other way round.

What's actually going on

"Connection refused" means nothing is listening at the address you dialed — this is a networking problem, never a model problem. There are only four real causes: the server process isn't actually running; it's running but bound to 127.0.0.1 (localhost-only) while you're connecting from another machine, container, or VM; something else occupies the port so the server never started cleanly; or a firewall/Docker/WSL2 network boundary sits between client and server. The fixes below check them in that order — fastest first.

How to fix it

  1. 1

    Confirm something is actually listening on the portMost common fix

    Don't guess — look. If nothing is listening on 11434, start the server and watch the output for errors (a fresh install that was never started, a crashed service after an update, and a closed system-tray app are the boring, common realities). If this shows a listener, skip to the bind-address fix.

    multiple shells — see comments
    # macOS / Linux
    lsof -i :11434        # or: ss -ltnp | grep 11434
    
    # Windows (PowerShell)
    Get-NetTCPConnection -LocalPort 11434 -State Listen
    
    # Nothing listening? Start it and read the output:
    ollama serve
    # Linux service install:
    sudo systemctl status ollama
    Did it work?On the machine running Ollama, the root URL answers Ollama is running.
    multiple shells — see comments
    # bash, zsh or PowerShell 7 — in Windows PowerShell 5.1, type curl.exe instead of curl
    curl http://localhost:11434
    Check what fits your hardwareconfirm which models your hardware can serve once connectedOpen the VRAM checker →
  2. 2

    Connecting from another device? Bind to 0.0.0.0 instead of localhost

    By default Ollama listens on 127.0.0.1 — reachable only from the same machine. Any connection from your phone, another PC, or a VM gets refused by design. Set OLLAMA_HOST=0.0.0.0:11434 and restart, then connect using the host's real IP (e.g. http://192.168.1.50:11434), never "localhost" from the remote device. LM Studio has the same switch: enable "Serve on Local Network" in the server tab. And never expose these ports to the internet — the APIs have no authentication; for remote access use a VPN/tailnet setup instead.

    multiple shells — see comments
    # Linux (systemd)
    sudo systemctl edit ollama
    #   [Service]
    #   Environment="OLLAMA_HOST=0.0.0.0:11434"
    sudo systemctl restart ollama
    
    # macOS
    launchctl setenv OLLAMA_HOST "0.0.0.0:11434"
    # then quit & reopen the Ollama app
    
    # Windows: set OLLAMA_HOST=0.0.0.0:11434 in Environment Variables, restart Ollama
    Did it work?From another device, curl http://<host-ip>:11434/api/tags returns your model list as JSON.
  3. 3

    Docker containers: "localhost" is the container, not your machine

    The #1 Open WebUI issue: inside a container, localhost:11434 points at the container itself — where Ollama is not running. Use host.docker.internal (Docker Desktop on Mac/Windows) or the host-gateway mapping on Linux. If Ollama itself runs in a container, publish the port with -p 11434:11434.

    bash
    docker run -d -p 3000:8080 \
      --add-host=host.docker.internal:host-gateway \
      -e OLLAMA_BASE_URL=http://host.docker.internal:11434 \
      ghcr.io/open-webui/open-webui:main
    Did it work?Open WebUI lists your models. If the container image includes curl, curl http://host.docker.internal:11434 run inside it answers Ollama is running.
  4. 4

    WSL2: Windows and Linux are two different "localhost"es — sometimes

    Recent WSL2 forwards localhost automatically (Windows apps can reach a server started inside WSL at localhost:11434, and WSL can reach a Windows Ollama the same way) — but the forwarding breaks after hibernation, under VPNs, and with networkingMode changes. If localhost fails across the boundary, dial the other side's real address: from WSL, the Windows host is reachable at the gateway IP; from Windows, WSL is at the address wsl hostname -I prints. wsl --shutdown and restarting also resets broken forwarding.

    bash
    # From inside WSL2, find and use the Windows host:
    ip route show | grep default   # e.g. 172.29.0.1
    curl http://172.29.0.1:11434/api/tags
    
    # Forwarding glitched? Reset WSL entirely:
    wsl --shutdown
  5. 5

    Port already in use: find the squatter or move Ollama

    If ollama serve dies with "address already in use", another process owns the port — very often a *second* copy of Ollama (the desktop app running in the tray while you launch ollama serve in a terminal). Quit the tray app, or kill the PID holding the port. You can also relocate Ollama to another port entirely — just update every client to match.

    bash
    # Who owns the port?
    lsof -i :11434            # then: kill <PID>
    
    # Or run Ollama elsewhere:
    OLLAMA_HOST=127.0.0.1:11500 ollama serve
    curl http://localhost:11500/api/tags
    Did it work?ollama serve starts without the error, or a client pointed at the new port gets a response from /api/tags.
  6. 6

    Still refused from other machines? It's the firewall

    After binding to 0.0.0.0, an OS firewall can still drop outside connections: allow TCP 11434 through ufw/firewalld on Linux, approve the "allow incoming connections" prompt on macOS, and on Windows add an inbound rule (fastest test: temporarily toggle the firewall off — if connections work, it was the rule). Verify from the remote device with curl http://<host-ip>:11434/api/tags — a JSON model list means everything works end to end.

    multiple shells — see comments
    # Linux (ufw) — allow only your LAN:
    sudo ufw allow from 192.168.1.0/24 to any port 11434 proto tcp
    
    # Windows (admin PowerShell):
    New-NetFirewallRule -DisplayName "Ollama" -Direction Inbound -LocalPort 11434 -Protocol TCP -Action Allow

If none of this worked

If the server listens on the right address and the port is open, look at what sits between the two machines: a VPN client, guest Wi-Fi isolation or a third-party firewall suite can each block traffic that the operating system's firewall allows. Before opening the API to anything beyond your own network, read the security notes in the remote-access pages below.

Include this when you report it
  • The exact error and the URL the client uses
  • Output of the listening-port check on the server
  • Where client and server each run: same machine, another device, Docker or WSL2
  • ollama -v, and how you start Ollama: the app, ollama serve or systemd
Also affects: Linux · Apple

Related

Frequently asked questions

What port does Ollama run on by default?

TCP 11434, bound to 127.0.0.1 (localhost-only). LM Studio's server defaults to port 1234. Both can be verified with a browser: http://localhost:11434 returns "Ollama is running", and /api/tags returns your model list as JSON.

Why can I chat in the terminal but the API gives connection refused?

Because the client is not reaching the server your terminal used. On macOS and Windows, ollama run starts the desktop app when no server is running, and the app keeps serving until you quit it; on Linux, ollama run starts nothing and fails unless the systemd service or ollama serve is up. So check the address and port the client dials: another host, a container or a changed OLLAMA_HOST.

Is it safe to set OLLAMA_HOST=0.0.0.0?

On a home LAN behind NAT, generally yes — it exposes the API to devices on your network only. It is NOT safe to port-forward it to the internet: the API has no authentication, so anyone could use your GPU, delete models, or fill your disk. For access from outside your home, use a mesh VPN like Tailscale instead of an open port.

Open WebUI shows "Ollama not detected" even though Ollama works — why?

Because Open WebUI runs in Docker, and its "localhost" is the container. Point OLLAMA_BASE_URL at http://host.docker.internal:11434 (with the host-gateway add-host flag on Linux) and it will find the API immediately.

curl works on the server but the connection times out (not refused) remotely — different problem?

Yes, and a useful clue: "refused" means reachable-but-nobody-listening, while a *timeout* means packets never arrived — that's a firewall or routing issue. Check the OS firewall rule for the port and that both devices are truly on the same network (guest Wi-Fi isolation is a classic culprit).