Skip to content

Remote Ollama stopped working #2667

Closed
Closed

Description

@HendrikSP

I had runnig opencode with ollama on a second computer in the local network. It was working fine.

One of the recent updates broke my installation and I'm unable to get it running again. (Since I use opencode only sometimes I cannot pinpoint the exact version that broke for me).

My config to reproduce this:

{
  "$schema": "https://opencode.ai/config.json",
  "disabled_providers": [ "opencode" ],
  "provider": {
    "ollama": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Ollama",
      "options": {
        "baseURL": "http://192.168.1.26:11434/v1"
      },
      "models": {
        "qwen3:8b": {
          "name": "Qwen3"
        }
      }
    }
  }
}

Then opencode replies to any prompt with "Error: Was there a typo in the url or port?"

Running opencode with log level Debug writes

ERROR 2025-09-18T07:25:08 +2ms service=session.prompt session=ses_6a4498a9dffesactQKgvG248ok error=Was there a typo in the url or port? model=qwen3:8b failed to generate title
ERROR 2025-09-18T07:25:08 +0ms service=session.prompt session=ses_6a4498a9dffesactQKgvG248ok error={"error":{"code":"FailedToOpenSocket","path":"http://192.168.1.26:11434/v1/chat/completions","errno":0}} stream error
INFO  2025-09-18T07:25:08 +1ms service=session.prompt session=ses_6a4498a9dffesactQKgvG248ok type=error part
ERROR 2025-09-18T07:25:08 +0ms service=session.prompt session=ses_6a4498a9dffesactQKgvG248ok error=Was there a typo in the url or port? process

to the log file.

Observations:

  1. I can curl the URL
  2. Other programs on my local computer communicate well with the remote ollama server
  3. Using the hostname of the server results in the same error (I use the IP to report the bug to avoid any influence may caused by DNS issues)
  4. Replacing the IP with localhost or 127.0.0.1 and running ollama locally DOES work!
  5. I disabled the opencode providers to avoid any clutter in the ui or selecting the right model. Removing the line form the config does not solve or change the problem.

opencode v0.9.11

Activity

  1. github-actions commented on Sep 18, 2025

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    The FailedToOpenSocket error you're experiencing when connecting to remote Ollama (but not localhost) appears to be related to how opencode handles remote Ollama connections, which has been reported before.

    Feel free to ignore if none of these address your specific case.

  2. HendrikSP commented on Sep 18, 2025

    @HendrikSP
    Author

    EDIT: I clear also ~/.cache/opencode

  3. HendrikSP commented on Sep 18, 2025

    @HendrikSP
    Author

    EDIT: I added an API key, same result.

  4. Dark-Kernel commented on Sep 18, 2025

    @Dark-Kernel

    It's working on my machine though

    Image

    i'm using qwen2.5:0.5b for testing purpose and it works.
    Please check if you ollama server is listening on all interface,

    Try running:
    ❯ curl http://192.168.1.26:11434/api/generate -d '{ "model": "qwen3:8b", "prompt": "What is water made of?" }'

    if it doesn't work, then set this environment variable

    OLLAMA_HOST=0.0.0.0:11434

  5. rekram1-node commented on Sep 18, 2025

    @rekram1-node
    Collaborator

    This seems like something specific to your setup rather than an opencode issue

  6. HendrikSP commented on Sep 18, 2025

    @HendrikSP
    Author

    Thank a lot for trying to reproduce it!

    However as stated initially I indeed can curl the remote Ollama and other AI applications work well:

    curl http://192.168.1.26:11434/api/generate -d '{ "model": "qwen3:8b", "prompt": "What is water made of?" }'
    {"model":"qwen3:8b","created_at":"2025-09-18T15:53:07.271567Z","response":"\u003cthink\u003e","done":false}
    {"model":"qwen3:8b","created_at":"2025-09-18T15:53:07.285369Z","response":"\n","done":false}
    {"model":"qwen3:8b","created_at":"2025-09-18T15:53:07.298985Z","response":"Okay","done":false}
    {"model":"qwen3:8b","created_at":"2025-09-18T15:53:07.312553Z","response":",","done":false}
    {"model":"qwen3:8b","created_at":"2025-09-18T15:53:07.326395Z","response":" the","done":false}
    {"model":"qwen3:8b","created_at":"2025-09-18T15:53:07.340083Z","response":" user","done":false}
    {"model":"qwen3:8b","created_at":"2025-09-18T15:53:07.353762Z","response":" is","done":false}
    {"model":"qwen3:8b","created_at":"2025-09-18T15:53:07.367425Z","response":" asking","done":false}
    {"model":"qwen3:8b","created_at":"2025-09-18T15:53:07.381219Z","response":" \"","done":false}
    {"model":"qwen3:8b","created_at":"2025-09-18T15:53:07.394836Z","response":"What","done":false}
    ...

    So its here only my opencode setup that is broken, but the debug log does any good hints. How can I debug this further?

  7. rekram1-node commented on Sep 18, 2025

    @rekram1-node
    Collaborator

    @HendrikSP can you curl the completions endpoint tho? /v1/chat/completions

  8. HendrikSP commented on Sep 18, 2025

    @HendrikSP
    Author

    Yes, i can:

    curl http://192.168.1.26:11434/v1/chat/completions -d '{ "model": "qwen3:8b", "messages": [ { "role": "user", "content": "What is water made of?" } ] }'
    
    {"id":"chatcmpl-681","object":"chat.completion","created":1758214346,"model":"qwen3:8b","system_fingerprint":"fp_ollama","choices":[{"index":0,"message":{"role":"assistant","content":"\u003cthink\u003e\nOkay, the user is asking, \"What is water m...
  9. HendrikSP commented on Sep 18, 2025

    @HendrikSP
    Author

    Hi, thank you for your help here. I went down the rabbit hole and tried a an simple example using ai-sdk directly. Not working. Tried to use just fetch. Not working. Found out that bun and node are affected. Tried a different Terminal App - works. It seems that Apple is blocking my other Terminal, but the only affected programs seems to be node and bun as far as I can tell. The Terminal App have permissions to access the local net. I will look into that myself now. Thanks again! :)

  10. Dark-Kernel commented on Sep 18, 2025

    @Dark-Kernel

    Damn.

  11. HendrikSP commented on Sep 18, 2025

    @HendrikSP
    Author

    PS: Working now everywhere. Seems an Update of the Terminal app and a long running tmux session was the problem. Why only the JS engines had been effected is not clear nor logical to me. :)

  12. pieterst67 commented on Oct 1, 2025

    @pieterst67

    PS: Working now everywhere. Seems an Update of the Terminal app and a long running tmux session was the problem. Why only the JS engines had been effected is not clear nor logical to me. :)

    I have the same problem, tmux getting blocked after a while and opencode gives an error when trying to connect to the llm server. Tmux kill-server solves the blocking, but this is not ideal...

  13. preflightsiren commented on Feb 4, 2026

    @preflightsiren

    just wanted to comment that I've been trying to debug the same behaviour; I normally use long running tmux sessions for everything and couldn't understand why I got the Error: Was there a typo in the url or port? error.

    Starting a terminal without tmux (raw bash or zsh for example), lets you run opencode connecting to remote ollama just fine.

    very weird behaviour 🤷

  14. rfrowe commented on Feb 28, 2026

    @rfrowe

    I ran into this. I did not have tmux running on either host or client machine. The only way I could get it to work was by SSH tunnel then changing the baseURL to 127.0.0.1

  15. idcrook commented on Mar 2, 2026

    @idcrook

    I ran into this. I did not have tmux running on either host or client machine. The only way I could get it to work was by SSH tunnel then changing the baseURL to 127.0.0.1

    I could not get to work. trying from macos (opencode) to windows (llama.cpp lllama-server /v1 openai). using the LAN IP address always is saying Error: Was there a typo in the url or port?

    my workstation is macos, and the GTX card is installed in a windows machine, so I am not willing to run opencode on windows.

  16. YukiGibson commented on Mar 3, 2026

    @YukiGibson

    Be careful if you use iTerm2, I switched to another terminal, in this case Ghostty and the local IP worked. Beforehand I had to SSH port forwarding. So yes check your local environment first, no idea why some terminals just block access to local IP's for now reason at all.

  17. idcrook commented on Mar 3, 2026

    @idcrook

    Be careful if you use iTerm2, I switched to another terminal, in this case Ghostty and the local IP worked. Beforehand I had to SSH port forwarding. So yes check your local environment first, no idea why some terminals just block access to local IP's for now reason at all.

    thanks for the tip. by the way, I tried enabling debug logging verbosity and I couldn't find any difference in the log file. the most frustrating thing on this is lack of visibility into the error/conditions.

  18. idcrook commented on Mar 3, 2026

    @idcrook

    I installed Ghostty on my macos, ran opencode uninstall and then brew install opencode, saving my old config.json into config directory and starting opencode in a ghostty session.

    There were macOS network access dialog and Little Snitch (firewall) warnings I had to allow. Got Error: Was there a typo in the url or port the first time I tried /init.

    but then after approving the access to LAN for firewalls, opencode started working with my llama.cpp llama-server qwen3-coder-next model running on another host in my LAN.

    it's possible that my iTerm2.app didn't have the right firewall allowances which led to the earlier errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions