Deploy a Cursor app on Railway: from localhost to live
Short answer: to deploy an app built in Cursor on Railway, push its code to GitHub, connect that repository to a Railway service, configure the production build and start commands, and add the environment variables the app needs. Cursor generates and edits code; the framework in that repository determines how it runs in production.
Identify what Cursor actually built
Before opening a hosting dashboard, ask Cursor to explain the repository. Request the framework, package manager, production build command, production start command, required variable names and persistent storage dependencies. Have it point to the files supporting each answer.
| What is in the repository? | What to check before deploying |
|---|---|
| A static frontend | Build output and a production static-file server |
| A Node or Python API | Start command, listening port and backend secrets |
| A server-rendered application | Framework server output and runtime dependencies |
| Separate frontend and backend folders | Which folder and command belong to each service |
Run the production build locally. A working development preview does not prove that dependencies, imports and routes survive a production build. Keep the package lockfile in Git so the hosting build uses the dependency versions you reviewed.
If the repository contains multiple apps, use the monorepo deployment guide to distinguish independent folders from shared workspaces before selecting root directories and per-service commands.
Deploy the repository
- Prepare the commit. Exclude real
.envfiles, passwords and generated uploads. Commit an.env.examplecontaining variable names and harmless placeholders. - Push to GitHub. Confirm the repository and branch contain the changes you want online.
- Create a Railway project from that repository. Grant access to the intended repository. In a monorepo, select the application folder for the service.
- Check the detected commands. Use your framework’s production process. Do not assume a development command becomes suitable because it starts successfully.
- Add configuration. Set backend credentials in the service’s Variables tab. Treat frontend configuration separately, as explained in the environment variables guide.
- Deploy and inspect the runtime logs. Confirm that the application stays running before generating a public domain.
- Test the generated URL. Open a deep link, submit a form and exercise a server request. Test from a private browser window so a local session cannot hide a login problem.
Railway documents the repository deployment flow in its quick start, and branch-triggered deployments in GitHub autodeploys. Check which branch the service follows before pushing experimental work.
Let Cursor help without hiding the deployment details
Railway’s official Cursor plugin connects the editor to Railway through its skill and hosted MCP server. The documented marketplace installation command is /add-plugin railway; authenticate the intended Railway account when prompted.
A useful request to your agent is:
Inspect this repository and propose the Railway service settings. Identify the production commands, required variable names, database dependency and health endpoint. Use placeholders for secrets and explain how I can verify the deployed commit.
Keep the resulting settings in the repository’s deployment notes. That gives you something concrete to compare when a later AI edit changes a package script or adds a dependency. An agent saying deployment succeeded should still be followed by opening the URL and completing the main user flow.
Add storage only when the app needs it
If your code expects PostgreSQL, Postgres with pgvector is one option in this directory. Its template includes a database, pooling and daily backups. You can use it for ordinary SQL without using vector search.
Deploy Postgres for your appDeploy the database into the app’s project and environment, then reference its private connection variable from the backend. Do not send a database password to browser JavaScript. Read database, cache and auth choices before adding more services.
Before sharing the link
Save a record through the public app, redeploy the same code and confirm that the record remains. Check that logout works, an unauthorized visitor cannot read another user’s records, and a failed API call produces a useful message. These checks catch different failures from a successful homepage response.
Review the pricing and free-plan guide before leaving an experimental stack running. Hosting costs, AI API usage and any external backend subscription are separate budget items. If the public page fails, start with the Railway 502 checklist, recording the error before changing settings.
FAQ
Can I deploy directly from Cursor to Railway?
Yes. Railway offers a Cursor plugin for authenticated deployment workflows. You can also push your code to GitHub and connect the repository in Railway, which makes the deployed commit easy to identify.
Does Railway host the code or does Cursor keep running?
Railway builds and runs your application. Cursor is your editor; closing it does not stop a successfully deployed service. External APIs and databases still need their own configuration.
Do I need a database template for every Cursor app?
No. A static page may need no database. Add one when your app needs persistent records, and match the database to the code rather than changing providers just to use a template.
Why does my app work locally but return a 502 on Railway?
Check the runtime logs, start command, listening address and port. A common cause is binding to localhost instead of 0.0.0.0 or listening on a different port from the service's target port.