Buy @ Amazon

Fix for Ollama Issue on Windows 11 where it doesn't connect

If you are using Ollama on Windows 11 machine and are encountering the error below:
Error: Head "http://0.0.0.0:11434/": read tcp 127.0.0.1:61593->127.0.0.1:11434: wsarecv: An existing connection was forcibly closed by the remote host.
Then it is likely that your previous force closure of Ollama left an abandoned process connecting to the said port - 11434. Unfortunately, at least in my case, this process didn't vanish even when I restarted the system that sure troubled me much.

The fix that worked for me was to identify the process-id of that rogue/abandoned process and kill it by its process-id. This is done in Windows Powershell (having admin privileges) like below: 
  • Find process-id using the command
    `Get-NetTCPConnection -LocalPort <port_number> | Select-Object -ExpandProperty OwningProcess`
    where you replace the <port_number> with actual port (11434 in this case) and this command outputs the PID of the process.
  • Kill the process using the PID that was output in the earlier step, using the command `Stop-Process -Id <PID> -Force`.