// libSQL error reference

connection reset / interrupted: Connection reset or dropped

The network path to the server dropped mid-request: the socket closed, the request timed out, or a proxy cut the connection.

エラー
connection reset / interrupted
カテゴリ
Remote server and Hrana errors
エラーメッセージ
The connection was interrupted while communicating with the server

意味

Remote libSQL runs over HTTP/WebSocket. Any hop between client and server can drop: TLS handshake failure, a load balancer idle timeout, a WebSocket closed by the server, or plain network loss. The client sees a closed socket or an interrupted request rather than a server error, so no HTTP status arrives. These failures are usually transient, and a retry often succeeds.

よくある原因

  • Network loss between client and server, including wifi and VPN blips.
  • An idle WebSocket closed by a proxy or load balancer timeout.
  • Server restart or failover on the remote database.
  • The client gave up on a request that exceeded its own timeout.

Find the cause

Decide first whether writes may have been applied before the drop: if the connection died mid-transaction, the transaction rolled back; if it died mid-batch with individual autocommit statements, some may have applied. Check by reading the data. Then look at where it dropped: a timeout with no bytes returned points at the network or proxy; a clean close right after connect points at the server refusing or restarting. `curl` to the same URL from the same machine separates your client from the network.

修正方法

  1. Retry idempotent reads and use transactions for multi-statement writes so a dropped connection cannot leave partial state:

    await db.batch(['INSERT ...', 'UPDATE ...'], 'write');
  2. Check reachability and latency by hand when it recurs:

    curl -s -o /dev/null -w '%{http_code} %{time_total}\n' https://mydb-myorg.turso.io/v2/pipeline
  3. Wrap remote calls in your own timeout; @libsql/client has no request timeout for remote clients (its timeout config is a local-file busy timeout):

    const res = await Promise.race([
      db.execute(sql),
      new Promise((_, rej) => setTimeout(() => rej(new Error('client timeout')), 10_000))
    ]);

Other ways to handle it

For HTTP-only clients, prefer the /v2/pipeline endpoint, which is stateless per request, over interactive transactions that need a live session. For flaky networks, embedded replicas keep reads local.

安全に再現する

Local and honest: start `turso dev --db-file scratch.db`, open a client, then kill the turso process mid-request to get a socket close. Real-world flakiness (proxies, TLS, wifi) cannot be reproduced offline; the kill-based repro only covers the server-gone-away shape.

質問

If the connection drops mid-transaction, did my writes apply?

An interactive transaction rolls back when its connection dies. A batch is atomic: all of it applies or none. Individual autocommit statements that already returned stay applied, so read the data back to check rather than replaying blindly.

Does @libsql/client have a request timeout option?

Not for remote clients. The timeout config sets a busy timeout and only affects local file: databases. For remote calls, wrap the promise in your own timeout (Promise.race with a rejected timer, or an AbortSignal on a custom fetch).

Why do my WebSocket connections die after quiet periods?

Proxies and load balancers close idle sockets. For long idle periods prefer the HTTP pipeline shape, or issue a cheap keepalive statement; either way treat the closed socket as a retryable failure.

関連エラー

More remote server and hrana errors errors

コードとメッセージのテキストは、 libSQL / Turso documentation。全容は次で参照 libSQL error list または すべてのデータベースエラーを検索.

// エラーが減り、修正も速く

Work on libSQL in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for libSQL and the other databases you use.

このページのテキストとデータ: CC BY 4.0、出典は SQLly (sqlly.app) と明記してください。 コードと SQL スニペット: MIT. ライセンスの詳細 引用したエラーメッセージの文言は、各データベースベンダーに帰属します。