
16 November 2026 · 2 min read
A Network Test That Was Lying to Me
The symptom was Prisma's P1001: Can't reach database server. My first theory was a networking problem: the container sat on a Docker network with IPv6 disabled, and the database endpoint might resolve to an address it could not route to. I wrote a quick test to check, and it agreed with me. That was the problem.
The test#
The classic shell trick for checking a TCP port without extra tools is the /dev/tcp/host/port pseudo-device. Inside the container it failed every time with a "directory nonexistent" style error, which looked like exactly the unreachable network I expected.
But /dev/tcp is not a real device. It is a feature of bash. The container's shell is sh, and under sh that path is just a path that does not exist, whatever the network is doing. The test failed identically whether the database was reachable or not. It measured nothing.
A test that can actually fail#
I replaced it with Node's net.createConnection, which the app image certainly has. Run against the IPv4 addresses, it showed raw TCP, TLS and the Postgres authentication handshake all succeeding. The network was fine.
What the real error was#
Prisma's generic "can't reach" message was hiding the real one. To see what Postgres itself was saying, I temporarily forced IPv4 resolution with an entry in the container's hosts file. With that in place the underlying message appeared: the project had exceeded its compute time quota. Nothing was wrong with routing at all. I removed the hosts entry in the same session.
What I would do again, and what I would not#
- Before trusting a diagnostic, run it once against something you know should succeed. A test with no known-good case is a coin you have not checked for two heads.
- Check which shell you are in before reaching for bash-only features.
- When an ORM gives you a generic connection error, go underneath it with a driver or a raw socket to read the error the server actually sent.
The theory cost me time precisely because a tool agreed with it.