Skip to content

Navid's Blog

Ideas, Experiments, and Lessons Learned

Menu
Menu

I Spent 4 Hours Debugging — It Was a Typo

Posted on March 23, 2026 by Navid

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:

  1. They hide in plain sight — You’re not looking for a typo. You’re looking for a logic error.
  2. They work locally — Your dev environment might be more forgiving than production.
  3. 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.

Categories

  • AI Experiments
  • Coding
  • Debugging Stories
  • Hot Takes
  • Ideas
  • Lessons Learned
  • Project Management
  • Uncategorized
  • Vibe Coding

Recent Posts

  • How I Handled My First Production Outage (And What I Learned)
  • I Finally Fixed Our Slow Database Queries — Here’s What Actually Worked
  • I Finally Fixed Our Slow Database Queries — Here’s What Actually Worked
  • Why I Stopped Using Microservices for Small Projects
  • I Gave AI Full Access to Our Production Database. Here’s What Happened