---
title: "Deploy Tianji"
description: "Self-host Tianji — website analytics, uptime and server status in one"
category: "Observability"
url: https://railway.com/deploy/tianji-fix-verify3
---

# Deploy Tianji

Self-host Tianji — website analytics, uptime and server status in one

**[Deploy Tianji on Railway](https://railway.com/template/tianji-fix-verify3)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/tianji-fix-verify3/manifest.json

- **Creator:** mcmax
- **Category:** Observability
- **Total deploys:** 1

## Template content

### tianji

- **Image:** moonrailgun/tianji:1.32.38
- **Public domain:** Yes

### postgres https://devicons.railway.app/i/postgresql.svg

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:18

## Documentation

# Tianji

Website analytics + uptime monitor + server status, in one dashboard. Not only another Google Analytics alternative — Tianji gives you real-time visitor tracking, uptime monitoring, and server health metrics in a single self-hosted platform.

Two services: Tianji (web app) + PostgreSQL (database).

## Deploy and Host

Host your own Tianji on Railway. This template provisions the all-in-one Tianji container (website analytics, uptime monitoring, server status reporting) and a PostgreSQL companion for persistence. All data persists in a Railway volume at `/var/lib/postgresql/data`.

[![Deploy to Railway](https://railway.app/button.svg)](https://railway.com/deploy/tianji-1)

## About Hosting

Tianji is a self-hosted analytics and monitoring platform. This template deploys it on Railway with a PostgreSQL companion database. All data persists in a Railway volume at `/var/lib/postgresql/data`. The app runs on port 8080 and is accessible via your Railway domain.

## Why Deploy

Tianji is the open-source analytics platform that combines three essential tools into one:

- **Website Analytics** — privacy-friendly alternative to Google Analytics with real-time visitor tracking, page views, and session analytics
- **Uptime Monitoring** — monitor your websites and services with instant downtime alerts
- **Server Status** — track CPU, memory, disk, and network metrics from your infrastructure

Running it on Railway gives you a durable, auto-updating, globally reachable instance with:

- **Full data ownership** — your analytics data lives on your Railway volume, not a third-party server
- **Real-time dashboards** — see visitor activity and server health as it happens
- **Alerting** — get notified when services go down or metrics cross thresholds
- **Reporter agents** — lightweight agents that collect and report metrics from your infrastructure
- **No ad stack** — plain self-hosted software, your analytics

## Common Use Cases

- **Privacy-conscious site owners** who want analytics without Google tracking
- **DevOps teams** who need unified uptime + server monitoring
- **Indie hackers** who want a single dashboard for all their projects
- **Agencies** who manage multiple client sites and need consolidated reporting

## Dependencies for Tianji

### Deployment Dependencies

The deploy form pre-fills all companion variables (DB host / name / user / password are wired to the PostgreSQL service via private-domain references — nothing to type).

**After the first successful deploy:**

1. Open your Railway public domain — the Tianji dashboard
2. Create your first workspace and website to start tracking
3. Add the tracking script to your website's head section
4. (Optional) Deploy the Tianji reporter agent to your servers for infrastructure monitoring

### Environment Variables

| Variable | Description | Default |
|----------|-------------|---------|
| `DATABASE_URL` | Full PostgreSQL connection string (auto-composed from PG* vars) | (empty) |
| `JWT_SECRET` | Random string for JWT signing (auto-generated) | (auto) |
| `ALLOW_REGISTER` | Allow new user registration | `false` |
| `ALLOW_OPENAPI` | Expose OpenAPI documentation | `true` |
| `PUBLIC_URL` | Public URL of this instance | (auto-filled) |
| `WEBSITE_ID` | UUID for self-tracking this instance | (empty) |
| `CLICKHOUSE_URL` | ClickHouse connection URL (optional) | (empty) |

## Service Architecture

- **tianji** — Main web application (analytics, uptime, server status)
- **postgres** — PostgreSQL 15 database companion

## Volumes

- `/var/lib/postgresql/data` — PostgreSQL data directory (persistent)

## Health Checks

- Tianji: `GET /health` on port 8080
- PostgreSQL: Built-in `pg_isready` check

## License

Tianji is open-source under the Apache License 2.0. This template is provided as-is for Railway deployment.


## Similar templates

- [Pyroscope profiling](https://railway.com/deploy/pyroscope-profiling) — Protected continuous profiling with durable Pyroscope storage.
- [SigOnly](https://railway.com/deploy/sigonly) — Deploy SigNoz with a working demo app & config in one click
- [Unwrapped Spotify Music Stats](https://railway.com/deploy/wide-bold) — Unwrapped Spotify Music Stats, Estatísticas de músicas disponíveis

Open this page in a browser: https://railway.com/deploy/tianji-fix-verify3
