Deploy libSQL Server
SQLite-compatible database server with token auth and a persistent volume
Just deployed
/var/lib/sqld
Deploy and Host libSQL Server on Railway
libSQL Server (sqld) is the server mode of libSQL, Turso's open-source, open-contribution fork of SQLite. It puts a SQLite-compatible database behind an HTTP and WebSocket API, so apps anywhere can query it with libSQL clients for TypeScript, Python, Rust or Go, or sync local embedded replicas from it.
About Hosting libSQL Server
This template runs the official libSQL Server v0.24.33 image, pinned by version and digest, built from a public GitHub repo. The database sits on a Railway volume at /var/lib/sqld, so it survives redeploys and restarts. Authentication is on from the first deploy: the template generates SQLD_AUTH_TOKEN, and the server rejects any query without it (it refuses to start with no auth at all). A public HTTPS domain and a /health check are set up for you. After deploying, copy LIBSQL_URL and SQLD_AUTH_TOKEN from the service's Variables tab into your app. Updates arrive as Railway "update available" notices when we bump the pinned version.
Common Use Cases
- A hosted SQLite-compatible database for web apps, APIs and serverless functions, using
@libsql/clientor another libSQL SDK - A sync source for embedded replicas, so apps read from a local SQLite file and write through to the server
- A self-hosted alternative to a managed Turso database for side projects, prototypes and internal tools
Dependencies for libSQL Server Hosting
- A Railway volume for the database files (included)
- A libSQL client in your app, with the URL and token from the service's variables
Deployment Dependencies
- libSQL repository and docs: https://github.com/tursodatabase/libsql
- Docker image reference: https://github.com/tursodatabase/libsql/blob/libsql-server-v0.24.33/docs/DOCKER.md
- Release used: https://github.com/tursodatabase/libsql/releases/tag/libsql-server-v0.24.33
- Template repo: https://github.com/aalfath/libsql-server-railway-template
Implementation Details
Connect from your app:
import { createClient } from "@libsql/client";
const db = createClient({ url: process.env.LIBSQL_URL, authToken: process.env.SQLD_AUTH_TOKEN });
await db.execute("SELECT 1");
From another service in the same project, use ${{libSQL.LIBSQL_PRIVATE_URL}} and ${{libSQL.SQLD_AUTH_TOKEN}} to stay on the private network. To rotate the token, change SQLD_AUTH_TOKEN and redeploy. For JWT authentication instead, add SQLD_AUTH_JWT_KEY (an Ed25519 public key). Download a SQL backup with curl -H "Authorization: Bearer YOUR-TOKEN" https://YOUR-DOMAIN/dump.
Why Deploy libSQL Server on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying libSQL Server on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Template Content
