You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ECONNRESET: The socket connection was closed unexpectedly. For more information #59291
This error happens quite often. I don’t understand why, or how to fix it. My internet connection is excellent, and it’s definitely not a hardware issue.
Thanks for the report! This error can come from several different causes, so we need a few details to work out which one you're hitting:
OpenCode version (opencode --version), your OS, and how you installed OpenCode.
Where you see the error: the TUI, the desktop app, opencode run, or a third-party front end. Please paste the full error text or a screenshot.
Provider and model you're using (e.g. OpenCode Zen/Go, Anthropic, OpenAI, or a custom/OpenAI-compatible endpoint).
When it happens: on the first message after OpenCode has been idle for a while, partway through a long response or tool call, after a fixed amount of time, or only in one large session.
Any proxy, VPN, firewall or security/antivirus software (e.g. Zscaler, CrowdStrike) on your machine or network.
If possible, the logs from a run where it happens (start OpenCode with --print-logs, or attach the log file).
You can reply here with the details, or edit the issue. If you edit it, please also leave a comment saying you've updated it, so we know you're done.
These existing issues may already cover your problem. They're ordered by likelihood:
Thanks for the error text and the screenshot, and for noting that it happens when a task is complex and the model takes a long time to answer. That helps narrow it down.
We still need a few details to work out which cause you're hitting, because this error has several:
OpenCode version (opencode --version), your operating system, and how you installed OpenCode.
Where you use it: the TUI, the desktop app, opencode run, or another front end.
Provider and model (e.g. OpenCode Zen/Go, Anthropic, OpenAI, Google Vertex/AI Studio, or a custom/OpenAI-compatible endpoint).
Roughly how long the model has been working when the error appears. For example, is it always about 60 seconds, or does it vary? Does it happen while the model is writing a large file or edit?
Any proxy, VPN, firewall or antivirus/security software on your machine or network.
If possible, logs from a run where it happens (start OpenCode with --print-logs, or attach the log file).
You can reply here with the details, or edit the issue. If you edit it, please also leave a comment saying you've updated it, so we know you're done.
These existing issues may already cover your problem. They're ordered by likelihood:
Following up with diagnostics from a machine that hits this regularly.
Environment
OpenCode 2.2.4, desktop app for Windows (per-user install at %LOCALAPPDATA%\Programs\ai.opencode.desktop\OpenCode.exe)
CLI @opencode/[email protected] (npm global), so client and server versions match
Windows 11 Pro 21H2, 10.0.22000, x64
Error appears in the desktop app. The bundled background service logs it server-side in %USERPROFILE%\.local\share\opencode\log\opencode.log; there is no external proxy in front of it.
Error text
timestamp=2026-10-30T22:21:20.916Z level=ERROR run=<id> message="Failed to drain Session"
cause="AI.Error: ECONNRESET: The socket connection was closed unexpectedly. For more information, pass `verbose: true` in the second argument to fetch()
at a (B:/~BUN/root/chunk-fgtjesq4.js:6:4214)
at <anonymous> (B:/~BUN/root/chunk-4e2rqd16.js:18:6047)
at runLoop (B:/~BUN/root/chunk-4e2rqd16.js:18:2552)
...
at SessionStep.attempt (B:/~BUN/root/chunk-z20sjgqk.js:382:3574)
at SessionRunner.runStep (B:/~BUN/root/chunk-z20sjgqk.js:382:2672)
at SessionRunner.drain (B:/~BUN/root/chunk-4e2rqd16.js:18:2552)
at ServerProcess.start (B:/~BUN/root/chunk-94gxrctf.js:2:7603)
[cause]: AI.Error.Transport: ECONNRESET: The socket connection was closed unexpectedly. ...
[cause]: TypeError: The socket connection was closed unexpectedly. ...
} role=server sessionID=ses_...
Stack trimmed for brevity; the wrapper is always Failed to drain Session, with AI.Error.Transport: ECONNRESET underneath.
Frequency
43 events in the current log (15.8 MB, covering 2026-09-07 04:41Z to 2026-10-31 00:56Z), all in bursts:
UTC hour
events
2026-09-07 04
1
2026-10-24 15
2
2026-10-24 18
2
2026-10-29 20
1
2026-10-30 19
4
2026-10-30 20
10
2026-10-30 21
6
2026-10-30 22
7
2026-10-30 23
9
2026-10-31 00
1
37 of them fall between 2026-10-30 19:25Z and 2026-10-31 00:56Z. Gaps are irregular: from 0.2 to 103 minutes. The tightest cluster is 22:59:25Z-23:13:15Z — 12 resets in 14 minutes, sometimes 11-21 seconds apart. So this does not look like a keep-alive or idle timeout on a fixed schedule.
When it happens
During long streaming turns, especially tool-heavy ones with slow commands, but also on turns where the only long-lived stream is the model response itself. Short prompts do not reproduce it.
Provider / model
Per-event attribution is not available in the log: sessions that reset only appear in the ERROR lines, without a matching message=stream providerID=... line. Models used on this machine in the same period: opencode/big-pickle (8099 streams), opencode/hy3-free (1137), ollama/gemma4:31b-cloud (160). Providers: opencode and ollama.
Network
No proxy, VPN, or TLS-inspecting security product on the machine. The ISP does intermittently interfere with TLS handshakes to some domains, so a middlebox dropping long-lived connections is plausible — but the resets also happen on turns where the only long-lived stream is the model response itself.
Impact
Non-fatal: session state survives, but the turn aborts and has to be re-sent manually. 37 resets in one 5.5-hour session is disruptive.
Suggestion
#54154 (retry with backoff for transport errors) would cover most of this. Retrying idempotent streaming requests, or resuming from the last received chunk, would remove the manual step entirely.
We're closing this for now because we haven't heard back with the details we asked for: your OpenCode version, OS and install method, where you use it (TUI, desktop app or opencode run), the provider and model, and any proxy/VPN/security software or --print-logs output. This error has several possible causes, and we need those details to tell which one you're hitting.
If it still happens, please reply with those details, or open a new issue that includes them, and we'll take another look. In the meantime, #56344, #57875 and #54160 may cover your problem, so they're worth following.
stupid harness. Retrying in 2s · attempt 3 · ECONNRESET: The socket connection was closed unexpectedly. For more information, pass verbose: true in the second argument to fetch()
Retry due · attempt 3 · ECONNRESET: The socket connection was closed unexpectedly. For more information, pass verbose: true in the second argument to fetch()
I so
This should be fixed in the latest version. If you still see ECONNRESET after updating, please open a new issue with your opencode --version, OS, provider/model and any logs.
This should be fixed in the latest version. If you still see ECONNRESET after updating, please open a new issue with your opencode --version, OS, provider/model and any logs.
still error and response token very slow (~5 token /s), version: v2.2.7
Activity
opencode-agent commentedon Oct 26, 2026
Thanks for the report! This error can come from several different causes, so we need a few details to work out which one you're hitting:
opencode --version), your OS, and how you installed OpenCode.opencode run, or a third-party front end. Please paste the full error text or a screenshot.--print-logs, or attach the log file).You can reply here with the details, or edit the issue. If you edit it, please also leave a comment saying you've updated it, so we know you're done.
These existing issues may already cover your problem. They're ordered by likelihood:
verbose: truein the second argument to fetch() #53829: ECONNRESET in one large session with many images and tool calls; forking the session and compacting it fixed itkharitonovdo commentedon Oct 26, 2026
When a task is complex and the neural network takes a long time to process it, this error occurs. How can I fix it?
opencodejr commentedon Oct 28, 2026
Thanks for the error text and the screenshot, and for noting that it happens when a task is complex and the model takes a long time to answer. That helps narrow it down.
We still need a few details to work out which cause you're hitting, because this error has several:
opencode --version), your operating system, and how you installed OpenCode.opencode run, or another front end.--print-logs, or attach the log file).You can reply here with the details, or edit the issue. If you edit it, please also leave a comment saying you've updated it, so we know you're done.
These existing issues may already cover your problem. They're ordered by likelihood:
verbose: truein the second argument to fetch() #53829: ECONNRESET in one very large session; forking it and compacting it fixed itmagusy commentedon Oct 31, 2026
Following up with diagnostics from a machine that hits this regularly.
Environment
%LOCALAPPDATA%\Programs\ai.opencode.desktop\OpenCode.exe)@opencode/[email protected](npm global), so client and server versions match%USERPROFILE%\.local\share\opencode\log\opencode.log; there is no external proxy in front of it.Error text
Stack trimmed for brevity; the wrapper is always
Failed to drain Session, withAI.Error.Transport: ECONNRESETunderneath.Frequency
43 events in the current log (15.8 MB, covering 2026-09-07 04:41Z to 2026-10-31 00:56Z), all in bursts:
37 of them fall between 2026-10-30 19:25Z and 2026-10-31 00:56Z. Gaps are irregular: from 0.2 to 103 minutes. The tightest cluster is 22:59:25Z-23:13:15Z — 12 resets in 14 minutes, sometimes 11-21 seconds apart. So this does not look like a keep-alive or idle timeout on a fixed schedule.
When it happens
During long streaming turns, especially tool-heavy ones with slow commands, but also on turns where the only long-lived stream is the model response itself. Short prompts do not reproduce it.
Provider / model
Per-event attribution is not available in the log: sessions that reset only appear in the ERROR lines, without a matching
message=stream providerID=...line. Models used on this machine in the same period:opencode/big-pickle(8099 streams),opencode/hy3-free(1137),ollama/gemma4:31b-cloud(160). Providers: opencode and ollama.Network
No proxy, VPN, or TLS-inspecting security product on the machine. The ISP does intermittently interfere with TLS handshakes to some domains, so a middlebox dropping long-lived connections is plausible — but the resets also happen on turns where the only long-lived stream is the model response itself.
Impact
Non-fatal: session state survives, but the turn aborts and has to be re-sent manually. 37 resets in one 5.5-hour session is disruptive.
Suggestion
#54154 (retry with backoff for transport errors) would cover most of this. Retrying idempotent streaming requests, or resuming from the last received chunk, would remove the manual step entirely.
Happy to test a build with the retry patch.
opencodejr commentedon Oct 31, 2026
We're closing this for now because we haven't heard back with the details we asked for: your OpenCode version, OS and install method, where you use it (TUI, desktop app or
opencode run), the provider and model, and any proxy/VPN/security software or--print-logsoutput. This error has several possible causes, and we need those details to tell which one you're hitting.If it still happens, please reply with those details, or open a new issue that includes them, and we'll take another look. In the meantime, #56344, #57875 and #54160 may cover your problem, so they're worth following.
omandotkom commentedon Nov 10, 2026
stupid harness. Retrying in 2s · attempt 3 · ECONNRESET: The socket connection was closed unexpectedly. For more information, pass
verbose: truein the second argument to fetch()thanhchuongbmd commentedon Nov 11, 2026
Retry due · attempt 3 · ECONNRESET: The socket connection was closed unexpectedly. For more information, pass
verbose: truein the second argument to fetch()I so
neriousy commentedon Nov 12, 2026
This should be fixed in the latest version. If you still see ECONNRESET after updating, please open a new issue with your
opencode --version, OS, provider/model and any logs.thanhchuongbmd commentedon Nov 13, 2026
still error and response token very slow (~5 token /s), version: v2.2.7