02.03 · Concept
Why Local Is Not Production
Name the four ways your machine diverges from production: environment, filesystem, network topology and concurrent load.
No video curated for this lesson yet
This lesson is written, ordered and part of the path - the video slot is the only thing still open. We are working through Deployment lesson by lesson; 29 of 56 have their video so far.
The written notes below cover this idea in full - you lose nothing by reading instead of watching.
Local success proves only that code works on a developer machine. Production changes the environment, filesystem, network paths and concurrent load, so assumptions about .env files, writable directories, localhost services and single-request execution can break as soon as the app runs behind real infrastructure.
What this lesson answers
- why does code work locally but fail in production
- what differs between local development and production
- why localhost works locally but not after deployment
Notes
Why Local Is Not Production — Local development exists to give fast feedback on one machine, but it diverges from production in environment, filesystem, network topology, and concurrent load, so code that works locally can fail when deployed behind real infrastructure.
Key Concepts: - Environment differs: local may use `NODE_ENV=development`, `.env`, and `localhost`, while production often uses injected variables such as Kubernetes `ConfigMap`/`Secret` or Cloud Run environment variables.
References
Common questions
- Why is local development not a reliable production test?
- Local development optimises for fast feedback on one machine. Production adds platform-managed configuration, different process lifecycles, restricted filesystems, service discovery, load balancers and many simultaneous requests. Those differences expose bugs that a laptop setup will not trigger, especially around configuration, persistence, networking and shared mutable state.
- Why do file uploads work locally but fail after deployment?
- Many deployment platforms do not give your application a normal persistent writable project directory. Code that writes uploads, generated images or cache files beside the application may fail or lose data after restart. Use external storage for durable files and only treat documented temporary paths as disposable scratch space.
- Why should production code not connect to localhost services?
- In production, localhost means the running process or container itself, not your database or another service elsewhere. Deployed services are usually reached through DNS names, managed endpoints, private networks, load balancers or service mesh routing. Hardcoded local addresses should be replaced with environment-specific configuration.
