# Transaction timed-out: interactive transaction aborted

> Interactive transactions fail on clients or servers old enough to predate Hrana-over-HTTP streams, or when the server expires an idle stream; batches still work.

Source: https://sqlly.app/errors/libsql/interactive-transaction-aborted
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: `Transaction timed-out`
- Category: Remote server and Hrana errors

Error message:

```text
interactive transaction not allowed in HTTP queries
```

## What it means

Older sqld versions refused interactive transactions on stateless HTTP requests with exactly this message; current clients open a stream over HTTP (baton streams) and `db.transaction()` works with `https://` URLs. The failure is still real in three shapes: a pinned old client or server, a literal `BEGIN` sent as a pipeline statement, and interactive transactions left idle until the server expires the stream (`The stream has expired due to inactivity`) or times the transaction out (`Transaction timed-out`).

## Common causes

- A client or server old enough to predate Hrana-over-HTTP streams.
- A literal `BEGIN` (or `COMMIT`) sent as a statement through a pipeline request.
- An interactive transaction held open so long the server expired or timed it out.

## How to fix it

1. Upgrade the client first. Current @libsql/client runs `db.transaction()` over https URLs; long interactive sessions still do best on a WebSocket (`libsql://`) connection:

   ```sql
   const db = createClient({ url: 'libsql://mydb-myorg.turso.io', authToken });
   const tx = await db.transaction('write');
   ```
2. On HTTP-only clients, replace the transaction with a batch, which is atomic on the server:

   ```sql
   await db.batch([
     { sql: 'UPDATE accounts SET bal = bal - 10 WHERE id = 1', args: [] },
     { sql: 'UPDATE accounts SET bal = bal + 10 WHERE id = 2', args: [] }
   ], 'write');
   ```
3. Never send BEGIN/COMMIT yourself over HTTP:

   ```sql
   -- wrong over https:// URLs
   -- BEGIN;
   -- UPDATE ...;
   -- COMMIT;
   ```

## Reproduce it safely

```sql
Local and honest for the idle-stream shape: run `turso dev --db-file scratch.db`, open a transaction over any URL scheme with @libsql/client, and wait past the server's inactivity expiry; the next statement fails with the stream expired error. The legacy refusal itself only reproduces on an old pinned client or server version.
```

## How SQLly helps

SQLly runs statements autocommit by default, so the fastest check is the opposite of the usual: if your app fails on `db.transaction()` and SQLly runs the same two statements fine, version skew or a held-open transaction in the app is the difference.

## Questions

### Can I use db.transaction() with an https:// URL in @libsql/client?

Yes in current versions: the HTTP client opens a server-side stream and the transaction runs on it. Very old client or server versions refused interactive transactions over HTTP; if you see that refusal, upgrade before restructuring code.

### Why did my interactive transaction die after a pause?

The server expires idle streams (`The stream has expired due to inactivity`) and times out stale transactions (`Transaction timed-out`). Keep interactive transactions short, or express the work as a batch, which commits or rolls back as a unit.

### Can I send BEGIN and COMMIT as plain statements over HTTP?

No. Over HTTP each pipeline request should be self-contained; use the client's transaction API or `db.batch()`, which run inside an implicit server-side transaction.

## Related errors

- [`connection reset / interrupted`](https://sqlly.app/errors/libsql/connection-interrupted): Connection reset or dropped
- [`SQLITE_BUSY`](https://sqlly.app/errors/libsql/busy): SQLITE_BUSY: the database is busy

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