Skip to content
COL0
Back to blog
·2 min read·By Victor Barrera

It works on my computer but not on the server: 7 common causes

The most frequent reasons your app stops working when you publish it: environment variables, versions, permissions, ports, paths and more. How to diagnose them.

DeploymentErrorsDevOpsBeginners

“It works on my machine” is the most repeated (and most frustrating) phrase in development. The good news: the cause is almost always one of these seven.

1. Missing environment variables

Locally you have a .env file; on the server you did not copy it (rightly, it should not be in the repository) and nobody created it there. Symptom: database connection errors, undefined keys, a 500 error. Fix: define the variables on the server and check that the names match exactly.

2. Different versions

Your computer has Node 22 and the server has Node 16; or PHP 8.3 and the server PHP 8.1. Symptom: syntax errors or functions that “do not exist”. Fix: install the same version on the server that you develop with, and pin it in the project.

3. File permissions

The web server user cannot write to the folder where your app stores logs, cache or uploaded files. Symptom: a 500 error or “permission denied” when uploading an image. Fix: give write permission only to the folders that need it, without resorting to chmod 777.

4. Wrong port or address

Your app listens on localhost:3000 but Nginx points to 8080, or the app listens only on 127.0.0.1 when it should accept the proxy’s connection. Symptom: 502 Bad Gateway. Fix: confirm which port your app really runs on (ss -tlnp) and that the proxy points there.

5. Paths and capital letters

On Windows and macOS, Image.png and image.png are usually the same file. On Linux they are not. Symptom: images or files that do not load only on the server. Fix: use exactly the same name and avoid absolute paths from your computer.

6. Dependencies that were not installed

You installed something by hand on your machine and it is not in the dependency file, or the server installed only the production ones. Symptom: “module not found” or a missing class. Fix: check that everything the app uses is declared (package.json, requirements.txt, composer.json).

7. Firewall or unreachable database

Your database accepted local connections, and on the server it is on another machine or the firewall blocks the port. Symptom: connection timeouts. Fix: check host, port and user, and connect over a private network rather than opening the database to the internet. More in production database.

How to diagnose without guessing

  1. Look at the logs. Your application’s and the web server’s.
  2. Reproduce the error with a simple request (curl).
  3. Change one thing at a time.

If you are tired of guessing, tell us what error you see. It is exactly the kind of problem we solve in the free session.

Frequently asked questions

Where do I start looking for the error?

In the server logs: your application's (for example, with journalctl or the framework's log file) and Nginx's. Almost always the exact message tells you what is missing.

What does a 502 Bad Gateway error mean?

That Nginx could not talk to your application: usually because it is not running, because it listens on another port, or because it crashed on startup.

Free resource

Guide: How to start an industrial IoT project in Colombia

A short PDF with the checklist we use to evaluate feasibility, budget and connectivity before buying a single sensor. No marketing, just what a project lead needs to know.

  • ✓How to size connectivity (NB-IoT, LoRaWAN, satellite)
  • ✓Checklist for a 4 to 8-week pilot
  • ✓Budget structure by phase
  • ✓Typical mistakes and how to avoid them

Is your app not starting on the server?

Tell us what error you see. In the free session we diagnose it with you.

Book your free session