Deploy Shlink

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

Deploy Shlink

/var/lib/postgresql/data

Just deployed

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

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.


Template Content

More templates in this category

View Template
Rocky Linux
Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀

codestorm
51
View Template
Foundry Virtual Tabletop
Self-hosted virtual tabletop for role-playing games (license required)

Lucas
71
View Template
Letta Code Remote
Run a Letta Code agent 24/7. No inbound ports, just deploy.

Letta
52