n8levine
n8levine
RRailway
Created by n8levine on 3/9/2024 in #✋|help
Errors Connecting to Postgres with a Cron Job
Hi, I'm running a couple services on Railway, connected to a Postgres instance using the internal connection, which has been working great. Recently I set up a cron job trying to connect to the same Postgres, and sometimes it works fine, but intermittently it gets this error:
Error: getaddrinfo ENOTFOUND postgres.railway.internal

at /app/node_modules/.pnpm/[email protected][email protected]/node_modules/pg-pool/index.js:45:11

at processTicksAndRejections (node:internal/process/task_queues:95:5)

at PostgresDriver.acquireConnection (/app/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:21:24)
Error: getaddrinfo ENOTFOUND postgres.railway.internal

at /app/node_modules/.pnpm/[email protected][email protected]/node_modules/pg-pool/index.js:45:11

at processTicksAndRejections (node:internal/process/task_queues:95:5)

at PostgresDriver.acquireConnection (/app/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/cjs/dialect/postgres/postgres-driver.js:21:24)
When that happens it hangs the cron run as well, preventing any later ones from running (they say skipped). My regular app runs out of the same codebase with very little different but has no issues connecting. Any ideas what's going wrong here?
18 replies