GeezerVison is showing github.com — ECONNRESET: The socket connection was closed unexpectedly. For more information · Issue #59291 · anomalyco/opencode
ECONNRESET: The socket connection was closed unexpectedly. For more information #59291DescriptionThis 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. Reacted by Vladis, Salva Alcántara, Ray Tian and Gabriela Activityopencode-agent commented on 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 (
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:
Reacted by Vladis and RickRosten kharitonovdo commented on Oct 26, 2026 
ECONNRESET: The socket connection was closed unexpectedly. For more information, pass `verbose: true` in the second argument to fetch()
When a task is complex and the neural network takes a long time to process it, this error occurs. How can I fix it? Reacted by Vladis and RickRosten opencodejr commented on 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 (
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:
magusy commented on Oct 31, 2026 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.
Happy to test a build with the retry patch. opencodejr commented on 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-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.
omandotkom commented on Nov 10, 2026 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() thanhchuongbmd commented on Nov 11, 2026 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 neriousy commented on 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 commented on Nov 13, 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.
still error and response token very slow (~5 token /s), version: v2.2.7 thanhchuongbmd commented on Nov 18, 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.
call tool take 200s, 171s, 226s, 175s
OS: MacOS 15.x, chip M1
Model: Any on OpenCode Go => I try z.ai is very fast
A task run in 15m => very slow, current effort is low, and the task is very easy NerdyShawn commented on Nov 26, 2026 Fresh data point on v2.4.1 (service, Linux, opencode-go/qwen3.8-flash): resets arriving before the first token terminate the turn with an empty message and no retry lines in the log — so the Nov 12 'fixed in latest' does not cover this path. Details and evidence in #66681.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|