2 years ago
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/pg-pool@3.6.1_pg@8.11.3/node_modules/pg-pool/index.js:45:11
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at PostgresDriver.acquireConnection (/app/node_modules/.pnpm/kysely@0.26.3/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?
15 Replies
Also I've experimented with various cron intervals, but that doesn't seem to help much
2 years ago
nixpacks or dockerfile based build?
2 years ago
do you have a 3 second sleep in your start script?
Status changed to Solved Railway • almost 2 years ago
2 years ago
yes it's needed because the private network is not available for the first 3 or so seconds
ooh interesting. That probably explains it then, it's basically just racing and sometimes is slow enough to wait for the network, other times not
2 years ago
it is
2 years ago
though whoever wrote that got the time very wrong
2 years ago
sounds good!