Skip to main content

Command Palette

Search for a command to run...

It Works on My Machine. Here's Why It Will Break in Production.

Published
10 min read
It Works on My Machine. Here's Why It Will Break in Production.

Every developer says this at least once.

"It works on my machine."

At first, it sounds like proof. The page loads, the login works, the API responds, the database has data, and the button does exactly what it should. You test it again and again on your laptop. Everything looks fine.

So the project must be done, right?

Not really.

"Works on my machine" is a common problem in software development where an application runs correctly in a developer's local environment but fails when deployed to a server — because the two environments have different configurations, software versions, and dependencies.

In software development, "it works on my machine" is one of the most dangerous sentences. Not because the developer is lying, but because it hides a bigger problem. Your app may work perfectly in the place where you built it, but that does not mean it will work in the place where real users will use it.

Your laptop is the easiest environment your project will ever face. It has your operating system, your installed tools, your saved environment variables, your local database, your file structure, and all the small fixes you made along the way. A production server has none of that unless you set it up properly.

That is why localhost is not enough.

This article explains what the "works on my machine" problem really means, why deployment is a separate skill, and how you can prove your project actually works.


What "Works on My Machine" Really Means

When you say your project works on your machine, you are saying one specific thing: it works in your local environment.

Your local environment is your laptop, your operating system, your software versions, your installed packages, your database, your file paths, your environment variables, and your saved settings. Everything is familiar to the project because you built it there.

A production server is completely different.

Let us say you build a tuition center management app for a Pokhara-based institute. On your laptop, everything works. The admin can log in, teachers can add students, students can check notices, and the database shows the right records.

Then you deploy the same project to a server.

Suddenly, it breaks.

The server has a different Node version. PostgreSQL is not configured. The .env file is missing. The upload folder does not exist. The app runs on port 3000 locally, but the public website needs port 80 or 443.

The code is the same. The environment is not. That is the real problem.

"Works on my machine" does not mean "works in production." It only means your project passed the easiest test it will ever face.


Why Deployment Is a Separate Skill

Deployment is not just uploading code to a server.

Deployment is the skill of making your app run reliably in an environment you did not build it in.

That requires a different set of skills from building features. You need to understand environment setup, dependency management, port configuration, database connection, security basics, and how to keep the app running after you close the terminal.

This is where many beginner developers get stuck. They know how to build the app, but they have never treated launching it as part of the work. This happens a lot with students, fresh graduates, and freelancers in Nepal. A project works during the local demo, but when the client asks for a live link, the real problems begin.

The server is not ready. The database is not connected. The API URL still points to localhost. The secrets are missing. The app stops the moment SSH is closed.

This does not mean the developer is bad. It means deployment was never treated as part of the project.

But in the real world, clients and companies do not only need code. They need working software.


The 5 Most Common "Works on My Machine" Failures

Most deployment failures are not mysterious. They happen because something exists on your laptop that does not exist on the server. Here are the five that break beginner projects most often.

1. Different OS or Architecture

You may develop on Windows or macOS, but the server likely runs Linux. That changes file paths, commands, permissions, and package behavior.

For example, this path works on your Windows laptop:

C:\Users\YourName\project\uploads

But it will not work on an Ubuntu server, where the path looks like this:

/home/ubuntu/project/uploads

If your code depends on your own laptop's file structure, it breaks the moment it moves anywhere else.

2. Missing Dependencies

Sometimes your project works because you installed something globally on your machine. For example, you may have installed nodemon globally, so the command works locally. But on the server, it does not exist.

Then you see:

command not found: nodemon

The server is not wrong. Your setup is incomplete. A proper project makes all dependencies explicit through files like package.json, requirements.txt, or a Dockerfile — so any machine can install exactly what is needed.

3. Hardcoded Paths

A beginner may write a file path that only exists on their own laptop. It works locally, but breaks the moment the app moves anywhere else. Instead of depending on personal folder structures, your app should use project-relative paths or environment-based configuration.

4. Missing Environment Variables

Your app needs values like DATABASE_URL, JWT_SECRET, API_KEY, PORT, and NODE_ENV. On your laptop, these live in your .env file. But that file should never be pushed to GitHub because it contains secrets.

So when the project reaches the server, those values are missing. The app cannot connect to the database, sign tokens, call an API, or start properly.

A good practice is to include a .env.example file that shows what values are required without exposing the real ones:

DATABASE_URL=
JWT_SECRET=
API_KEY=
PORT=
NODE_ENV=

Anyone setting up the project then knows exactly what to fill in.

5. Port Conflicts

Your app runs on port 3000 locally, but production traffic comes through port 80 for HTTP or port 443 for HTTPS. That is why real deployments use Nginx — it receives public traffic and forwards it internally to your app:

User → Domain → Nginx → App (port 3000)

If you do not handle ports correctly, your app may be running on the server but still not opening in any browser.


Frequently Asked Questions

Why does my app work locally but not on the server? The most common reasons are a missing .env file, different software versions, missing dependencies, hardcoded file paths, or incorrect port configuration. Your local machine has years of hidden setup that a fresh server does not have.

What is the difference between a local environment and a production environment? Your local environment is your laptop — set up over time, with all your personal configurations. A production environment is a clean server that only has what you explicitly install and configure. It is unfamiliar to your app by default.

What should a .env.example file contain? It should list every environment variable your app needs, with the keys but not the actual values. This lets other developers — or your own server setup — know what configuration is required without exposing secrets.

How do you prove your project works outside your laptop? Deploy it to a real server. Use a cheap AWS EC2 instance, a DigitalOcean droplet, or a local virtual machine. If it runs there without you manually fixing hidden dependencies, your setup is solid.


How to Prove Your Project Actually Works

You do not prove your project works by running it on your laptop. You prove it by making the setup repeatable — so anyone can run it in a clean environment without guessing what you did on your machine.

Write a real README. It does not have to be long, but it must be complete. Include the tech stack and required versions, all environment variables with a .env.example, database setup steps, local setup instructions, and deployment steps. A good README template looks like this:

## Tech Stack
Node 18, PostgreSQL 15, React 18

## Environment Variables
Copy .env.example to .env and fill in the values.

## Local Setup
1. npm install
2. Set up the database: psql -f schema.sql
3. npm run dev

## Deployment
The app expects Nginx to forward port 80 to port 3000.
See /docs/deployment.md for server setup steps.

Use environment variables for everything sensitive. Never hardcode API keys, database passwords, or production URLs inside your code.

Test the project outside your laptop. Use a cheap server, an EC2 instance, a DigitalOcean droplet, or even a virtual machine. For the cost of a few cups of coffee in Kathmandu, you can rent a small server for a month and learn more about deployment than most tutorials will ever teach you.

If the app runs cleanly on a fresh server — without you manually fixing anything — that is proof it works.


Why This Makes You a Stronger Developer

Most beginner portfolios show screenshots and GitHub links. That is a start, but it is not enough anymore.

If you can show that your project is deployed on a real server with proper documentation, you immediately look more serious than most candidates at your level.

Compare these two portfolio descriptions:

Built a tuition center management system using React, Express, and PostgreSQL.

versus:

Built and deployed a tuition center management system using React, Express, and PostgreSQL. Includes environment variable configuration, a documented local setup, and a live server deployment on EC2 with Nginx.

The second version is stronger because it shows ownership. It tells employers and clients that you did not only build the feature — you made the project usable for someone else.

When writing about your deployed projects, mention what you deployed to (EC2, DigitalOcean, Railway), how it is configured (Nginx, PM2, Docker), and that it has documentation. These three details alone separate you from most beginner portfolios in Nepal's job market.

Anyone can say they built a project. Fewer beginners can say they deployed it, documented it, and made it work outside their laptop.

That is a real advantage.


Conclusion

Working on your laptop is just the first step.

It proves your idea can run in the easiest environment it will ever face. But real software must run on a server, connect to a real database, use proper configuration, handle real users, and keep working after you close your terminal.

That is why "works on my machine" is not enough.

A developer who understands deployment can take a project beyond the demo stage. They can build it, launch it, and make it available to real people — not just show it running on their own screen.

A developer who can deploy is twice as valuable.