---
title: "Deploy TimescaleDB | (Just Updated) Postgres 17 Time-Series DB, Extension Enabled, Data Survives Redeploys"
description: "Postgres 17 + TimescaleDB, hypertables ready, data survives redeploys"
category: "Storage"
url: https://railway.com/deploy/timescaledb-or-just-updated-postgres-17-
---

# Deploy TimescaleDB | (Just Updated) Postgres 17 Time-Series DB, Extension Enabled, Data Survives Redeploys

Postgres 17 + TimescaleDB, hypertables ready, data survives redeploys

**[Deploy TimescaleDB | (Just Updated) Postgres 17 Time-Series DB, Extension Enabled, Data Survives Redeploys on Railway](https://railway.com/template/timescaledb-or-just-updated-postgres-17-)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/timescaledb-or-just-updated-postgres-17-/manifest.json

- **Creator:** SuperSlowSloth
- **Category:** Storage
- **Total deploys:** 1

## Template content

### timescaledb

- **Image:** timescale/timescaledb@sha256:b346edcdb51a1fd6020e3965e0bd1c9f3406fa6d5fbce1e28f4852587ef934e2
- **Start command:** `/bin/sh -c 'unset PGHOST PGPORT PGUSER PGPASSWORD PGDATABASE;M=$(cat /sys/fs/cgroup/memory.max 2>/dev/null); M=${M:-max}; [ "$M" = max ] && M=2147483648;MB=$((M/1048576));SB=$((MB/4)); [ "$SB" -lt 128 ] && SB=128;EC=$((MB*3/5)); [ "$EC" -lt 256 ] && EC=256;MW=$((MB/5)); [ "$MW" -lt 64 ] && MW=64; [ "$MW" -gt 2048 ] && MW=2048;WM=$((MB/64)); [ "$WM" -lt 4 ] && WM=4; [ "$WM" -gt 64 ] && WM=64;set -- $(cat /sys/fs/cgroup/cpu.max 2>/dev/null); Q=${1:-max}; P=${2:-100000};if [ "$Q" = max ]; then C=2; else C=$((Q/P)); fi;[ "$C" -lt 1 ] && C=1;PM=$((C/2)); [ "$PM" -lt 1 ] && PM=1; [ "$PM" -gt 4 ] && PM=4;export POSTGRES_USER=postgres POSTGRES_DB=railway TS_TUNE_MEMORY=${MB}MB TS_TUNE_NUM_CPUS=$C;echo "[railway] uid=$(id -u) owner=$(stat -c %u:%g /var/lib/postgresql) mem=${MB}MB cpu=$C shared_buffers=${SB}MB effective_cache_size=${EC}MB maintenance_work_mem=${MW}MB work_mem=${WM}MB dsm=mmap"; exec docker-entrypoint.sh postgres -c dynamic_shared_memory_type=mmap -c shared_buffers=${SB}MB -c effective_cache_size=${EC}MB -c maintenance_work_mem=${MW}MB -c work_mem=${WM}MB -c max_worker_processes=$C -c max_parallel_workers=$C -c max_parallel_workers_per_gather=$PM -c max_parallel_maintenance_workers=$PM'`

## Documentation

# Deploy and Host TimescaleDB on Railway

TimescaleDB is PostgreSQL extended for time-series data: hypertables that partition automatically by time, continuous aggregates, compression and retention policies, all queried with plain SQL. This template runs the official `timescale/timescaledb` image (PostgreSQL 17 with the extension preinstalled) as a single service from a digest-pinned image, with the database port on a Railway TCP proxy and a Railway volume holding the data.

## About Hosting TimescaleDB

- **The extension is ready on first boot.** The image enables `timescaledb` in the default database, so `create_hypertable(...)` works immediately.
- **A password is set from the first boot.** `POSTGRES_PASSWORD` is generated per deploy and a database named `railway` is created. Clients with the wrong password are refused.
- **Your data survives redeploys.** The volume is mounted at `/var/lib/postgresql` and PGDATA stays at its default subdirectory, so the `lost+found` folder Railway puts at the volume root never lands inside the data directory. The start command runs as root so the root-owned volume is writable, and prints the user id and mount owner in the deploy log so you can confirm it.
- **Memory and CPU follow your plan.** `shared_buffers`, `effective_cache_size`, `work_mem` and the worker counts are computed from the container's cgroup limits, not from the host's RAM, and the same figures feed `timescaledb-tune`.
- **Two ways in.** Services in the same project use the private URL; clients elsewhere use the TCP proxy URL.

## Common Use Cases

- IoT and sensor data, metrics and observability storage
- Financial tick data and event logs
- Application analytics with continuous aggregates
- A PostgreSQL database with time-series features for any app that already speaks Postgres

## Dependencies for TimescaleDB Hosting

- One Railway volume for the data directory (created by the template)

### Deployment Dependencies

- TimescaleDB documentation: https://docs.timescale.com/
- Official image: https://hub.docker.com/r/timescale/timescaledb

### Implementation Details

| Variable | Purpose |
| --- | --- |
| `POSTGRES_PASSWORD` | Password of the `postgres` user, generated per deploy. |
| `DATABASE_PRIVATE_URL` | Connection string on the private network, for services in the same project. |
| `DATABASE_URL` | Connection string on the TCP proxy, for clients outside Railway. |

Connect from your machine:

```bash
psql "$DATABASE_URL" -c "CREATE TABLE m(t timestamptz NOT NULL, v float8); SELECT create_hypertable('m','t');"
```

The image sends basic anonymous telemetry by default; set `timescaledb.telemetry_level=off` in `postgresql.conf` to disable it.

## Why Deploy TimescaleDB 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 TimescaleDB 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

- [TimescaleDB](https://railway.com/deploy/timescaledb-railway-template) — A PostgreSQL-based time-series database for analytics on Railway.
- [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

Open this page in a browser: https://railway.com/deploy/timescaledb-or-just-updated-postgres-17-
