// 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.

Error
connection reset / interrupted
Category
Remote server and Hrana errors
Error message
The connection was interrupted while communicating with the server

What it means

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.

Common causes

  • 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.

How to fix it

  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.

Reproduce it safely

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.

Questions

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.

Related errors

More remote server and hrana errors errors

The code and message text are from the libSQL / Turso documentation. Browse the full libSQL error list or search every database error.

// fewer errors, faster fixes

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.

Text and data on this page: CC BY 4.0, credit SQLly (sqlly.app). Code and SQL snippets: MIT. License details Quoted error message text belongs to its database vendor. View as Markdown