---
title: "Deploy Shlink"
description: "Self-hosted URL shortener with REST API, visit stats and web client"
category: "Other"
url: https://railway.com/deploy/shlink-1
---

# Deploy Shlink

Self-hosted URL shortener with REST API, visit stats and web client

**[Deploy Shlink on Railway](https://railway.com/template/shlink-1)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/shlink-1/manifest.json

- **Creator:** Agaz Self-Host
- **Category:** Other

## Template content

### Shlink https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/shlink.png

- **Source:** https://github.com/aalfath/shlink-railway-template
- **Health check:** /rest/health
- **Public domain:** Yes

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

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

### Shlink Web Client https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons/png/shlink.png

- **Source:** https://github.com/aalfath/shlink-railway-template
- **Health check:** /healthz
- **Public domain:** Yes

## Documentation

# Deploy and Host Shlink on Railway

Shlink is an open-source, self-hosted URL shortener with a REST API. It creates short links on your own domain, tracks visits (referrers, browsers, optional geolocation), generates QR codes, and supports tags, custom slugs and expiry rules. It comes with an official web client for managing links in the browser.

## About Hosting Shlink

Hosting Shlink means running its PHP application server, a SQL database for links and visits, and a way to manage links. This template deploys Shlink 5.1.8 on Railway Postgres and the official Shlink Web Client 4.9.0, both built from a GitHub repo with images pinned by digest. Shlink runs its database migrations on every start and creates an admin API key from a generated secret on first start. The web client is preconfigured with that server and key, and sits behind HTTP basic auth with a generated password, because it hands the API key to the browser. No values have to be entered at deploy time.

## Common Use Cases

* Branded short links on your own domain for marketing, social media and printed QR codes
* Tracking clicks per link without a third-party shortener collecting the data
* Creating short links from scripts, CI jobs or other apps through the REST API

## Dependencies for Shlink Hosting

* PostgreSQL (Railway Postgres, included)
* A public domain for the Shlink service (a Railway domain is added; a custom domain is recommended)

### Deployment Dependencies

* Shlink documentation: https://shlink.io/documentation/
* Shlink environment variables: https://shlink.io/documentation/environment-variables/
* Shlink releases: https://github.com/shlinkio/shlink/releases
* Shlink Web Client: https://shlink.io/documentation/shlink-web-client/
* Template repo and changelog: https://github.com/aalfath/shlink-railway-template

### Implementation Details

Services: **Shlink** (short links and REST API, health check `/rest/health`), **Shlink Web Client** (management UI, health check `/healthz`) and **Postgres**.

After deploy:

1. Open the Shlink Web Client domain and log in as `admin` with the `WEB_PASSWORD` value from that service's Variables tab.
2. Create links. They are served from the Shlink service's domain.
3. For API calls, send the Shlink service's `INITIAL_API_KEY` as the `X-Api-Key` header.

To use your own short domain, add it to the Shlink service under Settings, Networking, then set `DEFAULT_DOMAIN` on the Shlink service to `YOUR-DOMAIN`. Optional features are plain environment variables on the Shlink service: `GEOLITE_LICENSE_KEY` (a free MaxMind key) turns on visit geolocation, and `DEFAULT_BASE_URL_REDIRECT` and `DEFAULT_INVALID_SHORT_URL_REDIRECT` choose where the bare domain and unknown links send visitors.

Both app services build from the template repo, so new pinned releases arrive as Railway update notices; read the repo's `CHANGELOG.md` before applying one.

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

- [Rocky Linux](https://railway.com/deploy/rocky-linux) — Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀
- [Foundry Virtual Tabletop](https://railway.com/deploy/X5tR6G) — Self-hosted virtual tabletop for role-playing games (license required)
- [Letta Code Remote](https://railway.com/deploy/letta-code-remote) — Run a Letta Code agent 24/7. No inbound ports, just deploy.

Open this page in a browser: https://railway.com/deploy/shlink-1
