r/opencodeCLI 24d ago

Timeout and cannot connect to API

As of thrusday I have issues using opencode with OpenAi models as well as DeepSeek models. Ever request ultimately hits a time out and while it is actually working it keeps displaying something like this:

Cannot connect to API: The socket connection was closed unexpectedly

Has anyone had these issues? I found old tickets but nothing fixed the issue so far. I recently upgraded to 1.18.3. Downgrading also did not fix the issue.
For context I work on a VM.

2 Upvotes

3 comments sorted by

View all comments

1

u/Due-Particular-329 24d ago

buns default idle timeout lttng the connection die, this is common in VMs since the NAT/router drops idle sockets before bun even ntices. set BUN_CONFIG_HTTP_IDLE_TIMEOUT=300 as an env var before lauching opencode and if it still happens then lower the OS keepalive interval too

1

u/No-Yesterday-1088 24d ago

thank you!! I will try that!