Four hours. I wasted four hours chasing a bug that turned out to be a single missing character. Here’s what happened and why I’ll never make this mistake again.
The Scenario
I was working on a Node.js API that handled user authentication. Everything worked fine locally. But in production, certain login requests would just hang. No error. No response. Just silence.
The first thing I did was check the database. Then I checked the API logs. Then I added more logs. Then I started questioning my career choices.
The Investigation
For four hours, I went through every possible angle:
- Network timeouts
- Database connection issues
- Memory leaks
- Race conditions
- Even checked if the server was haunted (it wasn’t)
I was ready to rewrite the entire authentication module. That’s when I found it.
The Problem
In my environment config file, I had:
DATABASE_URL=postgres://user:pass@localhost:5432/mydb
But it should have been:
DATABASE_URL=postgres://user:pass@localhost:5432/mydb
Wait, that looks the same. Let me show you what actually happened:
DATABASE_URL=postgres://user:pass@localhost:5432/mydb
DATABASE_URL=postgres://user:pass@localhost:5432/mydb
The first one had a trailing space after the URL. Just one space. That invisible character made the database connection fail silently in production (where strict mode was enabled) but worked fine locally (where it wasn’t).
What I Learned
Here’s the thing about typos like this:
- They hide in plain sight — You’re not looking for a typo. You’re looking for a logic error.
- They work locally — Your dev environment might be more forgiving than production.
- Error messages lie — The error said “connection failed” but didn’t say why. I assumed it was a network issue.
What I Do Now
Since that day, I:
- Double-check all environment variables manually before deploying
- Use quotes around values in .env files (yes, even URLs)
- Validate env vars at startup — the app should crash loudly if something’s wrong
- Actually look at the raw values, not just assume they’re correct
Four hours for a space character. Painful? Yes. Memorable? Absolutely.
Sometimes the simplest bugs are the hardest to find. Not because they’re complex — but because you’re looking in the wrong direction.
