Why your app works locally but breaks when deployed
The usual reasons an app runs on your laptop but fails online: localhost addresses, missing variables, ports, CORS and data saved to local files.
Almost every “works on my machine” deploy failure comes from the same short list. Check these in order.
The checklist
- Hard-coded localhost: replace http://localhost:3000 with a setting.
- Missing environment variables: the host does not have your .env file. Add each one as a secret or setting.
- The wrong port: read PORT from the environment and listen on 0.0.0.0.
- CORS: the API must allow your new address.
- Unlisted dependencies: anything installed by hand is missing, so list it in requirements.txt or package.json.
- Build step not run: front-end projects must be built before they are served.
Data that vanishes
If the app saves to a local file or SQLite database, the data can disappear when the app restarts or rests. Keep data in a sheet, a database or the platform’s managed data instead.
Read the logs
The first error in the logs is usually the real cause. Your assistant can read them over MCP, fix the code and redeploy.
Questions
Why does my app work on localhost but not online?
Usually hard-coded addresses, missing environment variables, the wrong port or unlisted dependencies.
Why did my data disappear?
It was saved to the app’s own disk, which is not permanent. Use a database, a sheet or managed data.
How do I see the error?
Open the app’s logs.