
YOURLS
The de facto standard self-hosted URL shortener.
yourls
yourls:latest
Just deployed
MySQL
mysql:9
Just deployed
Deploy and Host YOURLS on Railway
YOURLS is a set of PHP scripts that will allow you to run Your Own URL Shortener, on your server. You'll have full control over your data, detailed stats, analytics, plugins, and more. It's free and open-source.
About Hosting YOURLS
Post-Deployment Setup
Once both services are running, click on the yourls
service and visit the .railway.app
domain generated for it. You can also add your own domain now, if you prefer.
When you visit the URL, you should see a “Forbidden” message
> If you see a Railway error, you’ll need to configure the ports for your app:
>
> 1. In Railway, click on the yourls
service.
> 2. Navigate to Settings, then scroll down to Networking.
> 3. Click on the Edit Icon, then click on → Edit Port.
> 4. If port 80
is showing, select that one. Otherwise, click + Custom Port, then enter 80
.
> 5. Click on Update, and your domain should now work!
From the domain with the “Forbidden” message, add /admin
to the end of the URL. This should redirect you to an installation page.
- Click on the Install YOURLS button.
- Once everything is successful, click on the YOURLS Administration Page link.
- Your username and password are created as part of the template.
- In Railway, click on the
yourls
service. - Navigate to Variables, then scroll down until you see
YOURLS_PASS
.- Note that there is a variable with the name YOURLS_DB_PASS — ignore this one.
- Hover over the variable and click the Copy button that appears.
- Head back to the login page and enter
admin
as the username (unless you changed it in the Variables tab) and the password you copied.
- In Railway, click on the
- You should now be signed in to your YOURLS instance!
Dependencies for YOURLS Hosting
Deployment Dependencies
Service | Version | Purpose | Source Image |
---|---|---|---|
YOURLS | latest | URL shortener | Docker Hub |
MySQL | 9 | Database | Docker Hub |
Environment Variables
Variable | Required | Default Value & Description |
---|---|---|
YOURLS_SITE | Yes | https://${{RAILWAY_PUBLIC_DOMAIN}} YOURLS instance URL, no trailing slash, lowercase. |
YOURLS_USER | Yes | admin YOURLS instance username. |
YOURLS_PASS | Yes | ${{ secret(32, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") }} YOURLS instance password. |
YOURLS_DB_HOST | No | ${{MySQL.MYSQLHOST}} Host for the database. |
YOURLS_DB_USER | No | ${{MySQL.MYSQLUSER}} User for the database. |
YOURLS_DB_PASS | No | ${{MySQL.MYSQLPASSWORD}} Password for the database. |
YOURLS_DB_NAME | No | ${{MySQL.MYSQL_DATABASE}} Database name. The database must have been created before installing YOURLS. |
YOURLS_DB_PREFIX | No | undefined Database tables prefix, defaults to yourls_. Only set this when you need to override the default table prefix. |
Resource Requirements
- Memory: Minimal
- CPU: Minimal
- Storage: No volume; database grows with usage
Troubleshooting
For common issues and community support, visit the Railway Community Forum.
Template Changelog
-
5 July, 2025
- Added descriptions to all environment variables and correctly marked optional ones
-
29 Jun, 2025
- Created template
Common Use Cases
- Brand-consistent marketing campaigns - Use your own domain for all shortened links to maintain brand recognition and trust
- Analytics and tracking - Monitor click-through rates, geographic data, and referrer information for marketing insights
- Internal link management - Create memorable short links for internal documentation, resources, and team sharing
- Social media optimization - Generate clean, trackable links for social media posts and email campaigns
- API integration - Programmatically create and manage short URLs through YOURLS' comprehensive REST API
Why Deploy YOURLS 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 YOURLS 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
yourls
yourls:latestMySQL
mysql:9