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

Source: https://sqlly.app/errors/libsql/connection-interrupted
Last updated: 2026-11-30
License: Text and data [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) (credit SQLly, sqlly.app); code and SQL snippets [MIT](https://opensource.org/license/mit). [Details](https://sqlly.app/license).
Note: Quoted error message text belongs to its database vendor.

- Error: `connection reset / interrupted`
- Category: Remote server and Hrana errors

Error message:

```text
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.

## How to fix it

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

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

   ```sql
   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):

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

## Reproduce it safely

```sql
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.
```

## How SQLly helps

SQLly's connection test does a single round trip and reports the raw failure, so 'works in SQLly, flaky in the app' usually means the app's own timeout or pool is cutting requests, not the network path.

## 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

- [`404 Not Found`](https://sqlly.app/errors/libsql/database-not-found-404): 404 Not Found: unknown database or endpoint
- [`SQLITE_BUSY: database is locked`](https://sqlly.app/errors/libsql/embedded-replica-locked): embedded replica file locked
- [`too many connections`](https://sqlly.app/errors/libsql/too-many-connections): Too many connections to one database

The code and message text are from the [libSQL / Turso documentation](https://docs.turso.tech/).
