---
title: "Deploy libSQL - Replica Node"
description: "SQLite with features like embedded replicas and remote access."
category: "Storage"
url: https://railway.com/deploy/libsql-replica-node
---

# Deploy libSQL - Replica Node

SQLite with features like embedded replicas and remote access.

**[Deploy libSQL - Replica Node on Railway](https://railway.com/template/libsql-replica-node)**

- **Creator:** yoshirakou
- **Category:** Storage

## Template content

### LibSQL- Replica Node https://turso.tech/favicon.ico

- **Image:** ghcr.io/tursodatabase/libsql-server:latest
- **Public domain:** Yes

## Documentation

**For Standalone** 
[![Standalone Node ](https://railway.com/button.svg)](https://railway.com/deploy/libsql-standalone)

**For Primary Node** 
[![Replica Node ](https://railway.com/button.svg)](https://railway.com/deploy/libsql-primary-node)

# Deploy and Host libSQL - Replica Node on Railway

libSQL - Replica Node is a read-oriented node that continuously synchronizes its database state from a libSQL Primary Node. It provides a locally accessible copy of the database and can serve application traffic without exposing the primary node directly. This template is specifically designed for a **replica node**, not a primary.

## About Hosting libSQL - Replica Node

Hosting libSQL - Replica Node means running a database node that connects to an existing libSQL Primary Node and replicates its database state.

This Railway template runs the official libSQL server in **replica mode** using `SQLD_NODE=replica`. The replica requires `SQLD_PRIMARY_URL` to point to the primary node's gRPC endpoint, ideally through Railway Private Networking.

Unlike the Primary Node template, this Replica Node is intended to be the public-facing database endpoint. Railway Public Networking can be enabled on the replica so applications can access the database without exposing the authoritative primary node directly to the internet.

## Common Use Cases

* Provide a public-facing libSQL endpoint while keeping the Primary Node isolated inside Railway's private network.
* Serve database reads closer to application services without directing all application traffic to the primary.
* Add one or more independently deployed replicas that synchronize from a single authoritative Primary Node.

## Dependencies for libSQL - Replica Node Hosting

* The official `ghcr.io/tursodatabase/libsql-server:latest` Docker image.
* An existing libSQL Primary Node that the replica can reach over Railway Private Networking.
* A valid `SQLD_PRIMARY_URL` pointing to the primary node's gRPC endpoint.

### Implementation Details

Run libSQL explicitly in replica mode:

```env
SQLD_NODE=replica
SQLD_PRIMARY_URL=http://:5001
SQLD_HTTP_LISTEN_ADDR=0.0.0.0:8080
```

Use the official Docker image:

```text
ghcr.io/tursodatabase/libsql-server:latest
```

`SQLD_PRIMARY_URL` must reference the Primary Node's gRPC service. When both services are deployed in the same Railway project or private network, use Railway Private Networking rather than exposing the Primary Node publicly.

For example:

```env
SQLD_PRIMARY_URL=http://libsql-primary.railway.internal:5001
```

Replace the hostname with the actual private hostname assigned to your Primary Node service.

### Networking Model

This template is designed so that **Railway Public Networking is enabled on the Replica Node, not on the Primary Node**.

Applications connect to the replica over its public HTTP endpoint, while the replica communicates with the Primary Node internally through Railway Private Networking.

A typical deployment topology is:

```text
Application
    │
    │ Railway Public Networking
    ▼
libSQL Replica
    │
    │ SQLD_PRIMARY_URL
    │ Railway Private Networking
    ▼
libSQL Primary
    │
    ▼
/data/sqld
```

The Primary Node remains isolated from direct public access and acts as the authoritative database source. The Replica Node acts as the externally reachable database service for applications.

Multiple replicas can be deployed and connected to the same primary when additional read capacity or independently exposed database endpoints are required.

This template does **not** create or configure a Primary Node. An existing Primary Node must be available before the replica can synchronize successfully.

## Why Deploy libSQL - Replica Node 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 - Replica Node 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.

## Similar templates

- [Garage S3 Storage](https://railway.com/deploy/garage-s3-storage) — Ultra-light S3 server: fast, open-source, plug-and-play.
- [Redis](https://railway.com/deploy/redis-1) — Self Host Latest Redis with Railway
- [EasyImg](https://railway.com/deploy/easyimg) — Simple self-hostable Nuxt.js personal image hosting system.

Open this page in a browser: https://railway.com/deploy/libsql-replica-node
