ollama icon indicating copy to clipboard operation
ollama copied to clipboard

Error: listen tcp 127.0.0.1:11434: bind:

Open szymonk92 opened this issue 1 year ago • 7 comments

Windows 10, I cannot start Ollama,

$ ollama serve
Error: listen tcp 127.0.0.1:11434: bind: An attempt was made to access a socket in a way forbidden by its access permissions.

from app.log

time=2024-02-21T10:04:42.504+01:00 level=WARN source=server.go:109 msg="server crash 332 - exit code 1 - respawning"
time=2024-02-21T10:04:43.018+01:00 level=ERROR source=server.go:112 msg="failed to restart server exec: already started"
time=2024-02-21T10:07:58.072+01:00 level=DEBUG source=logging_windows.go:12 msg="viewing logs with start C:\\Users\\user\\AppData\\Local\\Ollama"
time=2024-02-21T10:10:15.024+01:00 level=WARN source=server.go:109 msg="server crash 333 - exit code 1 - respawning"
time=2024-02-21T10:10:15.526+01:00 level=ERROR source=server.go:112 msg="failed to restart server exec: already started"
time=2024-02-21T10:11:20.094+01:00 level=DEBUG source=eventloop.go:151 msg="unmanaged app message, lParm: 0x204"
time=2024-02-21T10:11:20.792+01:00 level=DEBUG source=lifecycle.go:30 msg="QUIT called"
time=2024-02-21T10:11:20.842+01:00 level=INFO source=lifecycle.go:78 msg="Waiting for ollama server to shutdown..."
time=2024-02-21T10:15:48.537+01:00 level=DEBUG source=server.go:104 msg="server shutdown with exit code 1"
time=2024-02-21T10:15:48.537+01:00 level=INFO source=lifecycle.go:82 msg="Ollama app exiting"
time=2024-02-21T10:37:42.782+01:00 level=INFO source=logging.go:45 msg="ollama app started"
time=2024-02-21T10:37:42.863+01:00 level=DEBUG source=lifecycle.go:26 msg="starting callback loop"
time=2024-02-21T10:37:42.863+01:00 level=DEBUG source=store.go:61 msg="loaded existing store C:\\Users\\user\\AppData\\Local\\Ollama\\config.json - ID: 6fbe69d4-62a6-4ad8-9768-da087897ebe2"
time=2024-02-21T10:37:42.864+01:00 level=DEBUG source=lifecycle.go:57 msg="Not first time, skipping first run notification"
time=2024-02-21T10:37:42.865+01:00 level=DEBUG source=server.go:130 msg="heartbeat from server: Head \"http://127.0.0.1:11434/\": dial tcp 127.0.0.1:11434: connectex: No connection could be made because the target machine actively refused it."
time=2024-02-21T10:37:42.865+01:00 level=INFO source=server.go:131 msg="unable to connect to server"
time=2024-02-21T10:37:42.870+01:00 level=INFO source=server.go:87 msg="started ollama server with pid 40576"
time=2024-02-21T10:37:42.870+01:00 level=INFO source=server.go:89 msg="ollama server logs C:\\Users\\user\\AppData\\Local\\Ollama\\server.log"
time=2024-02-21T10:37:42.870+01:00 level=DEBUG source=eventloop.go:24 msg="starting event handling loop"
time=2024-02-21T10:37:42.941+01:00 level=WARN source=server.go:109 msg="server crash 1 - exit code 1 - respawning"
time=2024-02-21T10:37:43.445+01:00 level=ERROR source=server.go:112 msg="failed to restart server exec: already started"
time=2024-02-21T10:37:44.461+01:00 level=WARN source=server.go:109 msg="server crash 2 - exit code 1 - respawning"
time=2024-02-21T10:37:44.636+01:00 level=WARN source=tray.go:365 msg="failed to bring menu to foreground: The operation completed successfully."
time=2024-02-21T10:37:44.971+01:00 level=ERROR source=server.go:112 msg="failed to restart server exec: already started"
time=2024-02-21T10:37:45.525+01:00 level=DEBUG source=logging_windows.go:12 msg="viewing logs with start C:\\Users\\user\\AppData\\Local\\Ollama"
time=2024-02-21T10:37:45.882+01:00 level=DEBUG source=updater.go:87 msg="checking for available update at https://ollama.com/api/update?arch=amd64&nonce=RENbdDvJrUl9L0FRExH2xw&os=windows&ts=1708508265&version=0.1.25 with headers map[Authorization:[AAAAC3NzaC1lZDI1NTE5AAAAIAhd0mgYr2Vcgo+erwm80qQblGZaB2w4wE8iKVd5CEFx:dwydcT5JCB5WxCq5C7VD6Six77HhMVstFn6HMCBxU54YhtiEEYsOcHWMwC4EDADcM5NZD4oTgKf3/naoGa50CA==] User-Agent:[ollama/0.1.25 (amd64 windows) Go/go1.22.0]]"
time=2024-02-21T10:37:46.246+01:00 level=DEBUG source=updater.go:96 msg="check update response 204 (current version is up to date)"
time=2024-02-21T10:37:46.982+01:00 level=WARN source=server.go:109 msg="server crash 3 - exit code 1 - respawning"
time=2024-02-21T10:37:47.493+01:00 level=ERROR source=server.go:112 msg="failed to restart server exec: already started"
time=2024-02-21T10:37:50.502+01:00 level=WARN source=server.go:109 msg="server crash 4 - exit code 1 - respawning"
time=2024-02-21T10:37:51.016+01:00 level=ERROR source=server.go:112 msg="failed to restart server exec: already started"
time=2024-02-21T10:37:55.030+01:00 level=WARN source=server.go:109 msg="server crash 5 - exit code 1 - respawning"
time=2024-02-21T10:37:55.543+01:00 level=ERROR source=server.go:112 msg="failed to restart server exec: already started"

server.log

Error: listen tcp 127.0.0.1:11434: bind: An attempt was made to access a socket in a way forbidden by its access permissions.

What I tried: Ollama issue 2560, but seems that there is no proxy at that port

szymonk92 avatar Feb 21 '24 09:02 szymonk92

I found the same issue with above. Is there a solution?

xiaofeiyun123 avatar Feb 24 '24 14:02 xiaofeiyun123

same issue. i'm on wsl2 (debian 12) in windows 11 using ollama version 0.1.27 and an amd64 machine.

i checked that i have no proxies set using the following command.

netsh interface portproxy show all

here is what i ran and the output:

ollama run llama2 --verbose
Error: Head "http://127.0.0.1:11434/": dial tcp 127.0.0.1:11434: i/o timeout

kaczmarj avatar Feb 24 '24 18:02 kaczmarj

same error. any fix please?

Daviduche03 avatar Feb 25 '24 17:02 Daviduche03

Fixed by adding Environment="OLLAMA_HOST=0.0.0.0" in /etc/systemd/system/ollama.service

[Unit]
Description=Ollama Service
After=network-online.target

[Service]
ExecStart=/usr/local/bin/ollama serve
User=ollama
Group=ollama
Restart=always
RestartSec=3
Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
Environment="OLLAMA_HOST=0.0.0.0"

[Install]
WantedBy=default.target

then reload and restart

systemctl daemon-reload
systemctl restart ollama

hryyan avatar Feb 26 '24 12:02 hryyan

@Daviduche03 @szymonk92

I got the same issue.

the problem is down to Docker and Hyper-V reserving a shed load of ports

try the following, you will find the reserved the port 111434

netsh interface ipv4 show excludedportrange protocol=tcp

the simple way is run the following as admin.

net stop winnat
net start winnat

about the detail, please see the workaround at StackOverflow:Cannot bind to some ports due to permission denied

yiyuandao avatar Feb 28 '24 11:02 yiyuandao

@Daviduche03 @xiaofeiyun123 @szymonk92 In Windows 10, fixed by running ollama serve as admin.

Sadwy avatar Mar 06 '24 10:03 Sadwy

@szymonk92 have any of the suggestions above resolved your problem? We've designed Ollama to not require admin, but if some other app is using the port or has reserved the port that could explain the problem. Another workaround is to use a different port number by changing the OLLAMA_HOST environment variable. If you set that in your account and restart the App, then both the server and clients will use that new port number to connect.

See https://github.com/ollama/ollama/blob/main/docs/faq.md for more information.

dhiltgen avatar Mar 11 '24 23:03 dhiltgen

Fixed by adding Environment="OLLAMA_HOST=0.0.0.0" in /etc/systemd/system/ollama.service

[Unit]
Description=Ollama Service
After=network-online.target

[Service]
ExecStart=/usr/local/bin/ollama serve
User=ollama
Group=ollama
Restart=always
RestartSec=3
Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
Environment="OLLAMA_HOST=0.0.0.0"

[Install]
WantedBy=default.target

then reload and restart

systemctl daemon-reload
systemctl restart ollama

Hi, I set it up like this on ubuntu, but running ollama serve, I still get the error in this issue.

Pathsis avatar Apr 30 '24 16:04 Pathsis

@Pathsis can you share your server log?

dhiltgen avatar May 01 '24 17:05 dhiltgen

In windows, I created a new Environemnt variable: OLLAMA_HOST = 127.0.0.1:11435. Works for me. Refference: https://github.com/ollama/ollama/issues/2194

abmachinthosh avatar May 26 '24 22:05 abmachinthosh