Deploy Laravel
Deploy a Laravel PHP app with PostgreSQL and HTTPS in one click.
laravel
Just deployed
Just deployed
/var/lib/postgresql/data
Deploy and Host Laravel on Railway
Laravel is the most popular PHP framework, with 34,000+ GitHub stars on its core: routing, Eloquent ORM, queues, auth scaffolding and Blade templates. This template deploys a Laravel app with a PostgreSQL database and HTTPS on Railway in a few minutes. Heroku's always-on dyno plus database starts at $12/month — a small Laravel app on Railway typically runs for $3–8/month.
What This Template Deploys
| Service | Purpose |
|---|---|
| laravel | Laravel 11 app (PHP 8.2+, Vite assets) built from GitHub, public HTTPS domain. Sessions, cache and queue use the database driver. |
| Postgres | PostgreSQL with SSL, connected through DB_URL. |
| Persistent Volume | Mounted on Postgres at /var/lib/postgresql/data — your data survives redeploys. |
Two services, built by Railpack without a Dockerfile. APP_KEY and the database password are generated at deploy time.
About Hosting Laravel
Production Laravel needs PHP-FPM or a PHP server, a web server, a database, an APP_KEY, built frontend assets, migrations and somewhere for sessions and queues. On a VPS that's Nginx, PHP-FPM, Composer, Node and Supervisor to manage.
On Railway, Railpack installs Composer and Node dependencies, builds Vite assets and serves the app, while Postgres runs alongside it. Using the database driver for sessions, cache and queues means no extra Redis service to start with.
Two settings to change before launch. APP_DEBUG is true, which shows stack traces to visitors — set it to false. And DB_URL points at Postgres's public URL; switch it to ${{Postgres.DATABASE_URL}} to keep database traffic on Railway's private network. The starter uses Laravel 11; plan an upgrade to the current major release.
Typical cost: ~$3–8/month on Railway for the app and database. Heroku's Basic dyno is $7 plus $5 for the smallest Postgres.
Deploy Laravel in Under 5 Minutes
- Click Deploy on Railway — Railway forks the code, builds PHP and Vite assets and starts Postgres (~3–4 minutes).
- Set
APP_DEBUGtofalseandAPP_URLto your public URL on the laravel service. - Change
DB_URLto${{Postgres.DATABASE_URL}}for private networking. - Run
php artisan migratewith the Railway CLI (or add it to a pre-deploy command). - Clone your repository, build features and push — Railway redeploys.
No PHP-FPM tuning. No Nginx config. No server to patch.
Common Use Cases
- Laravel Forge or Heroku alternative — "deploy laravel app" without managing servers
- SaaS and web apps — Eloquent, auth and queues on a real database
- REST APIs — Laravel Sanctum-backed APIs for mobile or SPA frontends
- Admin panels — add Filament or Nova
- E-commerce and CMS builds — Laravel-based platforms on managed Postgres
- Learning and prototypes — a live Laravel app in minutes
Configuration
| Variable | Required | Description |
|---|---|---|
APP_KEY | 🔐 Auto-generated | Laravel encryption key. Never change it once users have sessions or encrypted data. |
APP_DEBUG | ✅ Change | true by default — set false in production. |
APP_URL | Recommended | Your public URL, used for links and asset URLs. |
DB_URL | ✅ Auto-injected | Postgres connection. Switch to the private DATABASE_URL. |
SESSION_DRIVER, CACHE_STORE, QUEUE_CONNECTION | Optional | database by default; move to Redis as traffic grows. |
MAIL_MAILER | Optional | log by default — configure a mail provider to send real email. |
APP_DEBUG=true exposes secrets. Laravel's debug error pages can reveal environment details; turn debug off before sharing the URL.
Laravel on Railway vs. Alternatives
| Laravel on Railway | Heroku | Render | Shared PHP hosting | |
|---|---|---|---|---|
| Monthly cost (app + database) | ~$3–8 usage | $7 Basic + $5 Postgres | Free tier sleeps; paid plus database | Low, varies |
| Managed Postgres in the same project | ✅ Included | ✅ Add-on | ⚠️ Free DB expires in 30 days | ⚠️ Usually MySQL only |
| Always-on app | ✅ Yes | ✅ On Basic | ⚠️ Free spins down | ✅ Yes |
| Queues and workers | ✅ Extra service | ✅ Worker dyno | ✅ Background worker | ❌ Rarely supported |
| Deploy on git push | ✅ Yes | ✅ Yes | ✅ Yes | ❌ FTP or manual |
| License | ✅ MIT Laravel, starter code yours | ❌ Proprietary platform | ❌ Proprietary platform | ❌ Proprietary platform |
Dependencies for Laravel Hosting
- Railway account — Hobby ($5/month) covers a small app and database.
- A GitHub account — Railway forks the starter so you own the code.
- A mail provider (Postmark, Mailgun, SES) when you need real email.
Deployment Dependencies
- Laravel Docs — framework reference
- Laravel on GitHub — releases
- Railpack — Railway's zero-config builder
- Railway Volumes Documentation — persistence
Implementation Details
Railpack detects composer.json and package.json, installs PHP and Node dependencies, builds assets with Vite and serves the app. Laravel connects to Postgres through DB_URL (DB_CONNECTION=pgsql), and the database driver backs sessions, cache and the queue.
Production checklist: APP_DEBUG=false, APP_URL set, DB_URL on the private network, migrations run on deploy, a real MAIL_MAILER, and an upgrade from Laravel 11 to a supported release.
Frequently Asked Questions
What does this Laravel template include? A Laravel 11 application with Vite-built assets and a PostgreSQL database, using the database driver for sessions, cache and queues, on a public HTTPS URL.
How much does Laravel hosting cost compared to Heroku? About $3–8/month in Railway usage for the app and database. Heroku is $7 for a Basic dyno plus $5 for its smallest Postgres.
Why does Laravel show a 500 error or "No application encryption key"?
APP_KEY must be set — this template generates it. For other 500s, check the deploy logs; with APP_DEBUG=false details go to the log instead of the page.
Do I lose data when I redeploy? No. Data lives in Postgres on a persistent volume. Files stored on the local disk reset on deploy — use a volume or S3 for uploads.
How do I run migrations and queue workers?
Run php artisan migrate through the Railway CLI or a pre-deploy command, and add a second service from the same repo running php artisan queue:work.
Is this starter production-ready?
Almost: turn APP_DEBUG off, use the private database URL, configure mail, and plan an upgrade from Laravel 11, whose security support has ended.
Why Deploy and Host Laravel 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 Laravel on Railway, you get a Laravel app and PostgreSQL with git-push deploys for a few dollars a month, without managing PHP servers.
Template Content