Railway

Deploy Dub: Self-Hosted Link Management

Self-host Dub link management, analytics, and QR codes

Deploy Dub: Self-Hosted Link Management

Just deployed

Just deployed

/var/lib/mysql

PlanetScale Proxy

acewebs/dub-railway

Just deployed

Deploy and Host Dub: Self-Hosted Link Management on Railway

Dub is an open-source link management and attribution platform for creating branded short links, managing custom domains, generating QR codes, tracking clicks and conversions, and running partner programs.

This community template adapts Dub for Railway by deploying the application with Railway MySQL and a PlanetScale-compatible HTTP proxy. The database services, internal networking, application domain, and core secrets are wired automatically.

Community-maintained template. Not affiliated with or endorsed by Dub. Dub is licensed under AGPL-3.0.

What This Template Deploys

The template creates three Railway services:

  • Dub — the Next.js web application and link redirect service
  • MySQL — the primary database for users, projects, links, and metadata
  • PlanetScale Proxy — a compatibility layer that allows Dub’s PlanetScale serverless driver to communicate with Railway MySQL

The template also configures:

  • Private database connectivity
  • Build-time and runtime database URLs
  • The Railway-generated application domain
  • NextAuth, encryption, and cron secrets
  • Database schema synchronization during deployment

This removes the need to provision a separate PlanetScale database or manually connect Dub’s two database access methods.

What You Can Use Dub For

  • Create short links using your own branded domains
  • Organize and manage campaign links
  • Generate QR codes for links and campaigns
  • Track clicks, referrers, devices, and conversions
  • Attribute signups, leads, and purchases to individual links
  • Build affiliate and partner programs with Dub Partners
  • Provide link management tools inside another application using Dub’s APIs

Additional Services Required

The Railway infrastructure is deployed automatically, but a working Dub installation still requires credentials for several external services.

Upstash

Dub uses:

  • Upstash Redis for caching link metadata and serving redirects
  • QStash for queues and background jobs

Add the Redis REST URL and token, together with the QStash token and signing keys, to the Dub service variables.

Tinybird

Dub uses Tinybird to store and query click-event analytics.

Create a Tinybird workspace, add its API URL and admin token, and deploy the Tinybird datasources included in the repository.

Click analytics will not work until these datasources have been deployed.

Object Storage

Dub stores project logos, user avatars, and custom social-card images in S3-compatible object storage.

Supported options include:

  • Cloudflare R2
  • Amazon S3
  • A separately deployed MinIO service

Configure the storage endpoint, access credentials, public and private bucket names, and public asset URL.

Authentication

Configure at least one login method:

  • GitHub OAuth
  • Google OAuth
  • Resend for email magic links

OAuth is generally the simplest option because it does not require an email delivery service.

For GitHub OAuth, use the following callback format:

https://your-domain.example/api/auth/callback/github

Getting Started

  1. Click Deploy and allow the Dub, MySQL, and PlanetScale Proxy services to build.
  2. Open the generated Railway domain so you know the final hostname.
  3. Create an OAuth application using that hostname for the callback URL.
  4. Configure Upstash Redis and QStash.
  5. Configure Tinybird and deploy Dub’s analytics datasources.
  6. Configure Cloudflare R2, Amazon S3, or MinIO.
  7. Add the required credentials to the Dub service variables.
  8. Redeploy the Dub service.
  9. Open the Railway domain and sign in.

To use your own application domain, add it to the Dub service and update NEXT_PUBLIC_APP_DOMAIN to the new hostname.

Your branded short-link domains can then be added and managed from inside Dub.

Important Deployment Notes

  • This is a Railway-ready fork of Dub rather than an automatically updated deployment of the latest upstream release. Review the repository before upgrading.
  • Tinybird datasources must be deployed separately before analytics becomes available.
  • The current fork documents compatibility differences between Tinybird Classic and newer Forward workspaces. Check the repository notes when creating your workspace.
  • Country and city analytics provided through Vercel-specific geolocation helpers may not be populated on Railway. Clicks and other available metadata are still recorded.
  • Dub’s scheduled API jobs are not created automatically. Add Railway Cron services for any scheduled jobs you need and authenticate them using CRON_SECRET.
  • Stripe billing and Upstash Vector integrations are optional and require additional credentials only when those features are enabled.
  • Because Dub uses the AGPL-3.0 license, modified versions made available over a network may require users to be given access to the corresponding source code.

Why Deploy Dub on Railway?

The official Dub architecture normally combines several infrastructure providers. This template moves the main application and relational database into one Railway project while retaining the external services Dub uses for caching, queues, analytics, and file storage.

Railway provides:

  • A persistent managed MySQL database
  • Private networking between application services
  • Generated and referenced environment variables
  • Centralized logs and deployment history
  • Custom domains and automatic TLS
  • Straightforward scaling for the Dub web service

The result is a practical starting point for running your own branded link-management and attribution platform without manually adapting Dub’s database architecture to Railway.


Template Content

PlanetScale Proxy

acewebs/dub-railway

More templates in this category

View Template
Matomo Analytics + MariaDB
Privacy-friendly analytics with MariaDB and persistent volumes.

leodev
0
View Template
Bugsink
Self-hosted Error Tracking. Sentry-SDK compatible

zǝʇɹoɔ oɓıɹpoɹ
18
View Template
SubTrackr
Self-hosted Subscription Tracker

amnesia
3