Replies: 6 comments 7 replies
-
Got the same issue! |
Beta Was this translation helpful? Give feedback.
-
Hey @BEpresent and @joschan21 — this is a problem with your database, and is not something related to Payload itself. It appears your connection is closing for some reason. Is your database hosted on Railway? I would bring this up with them or see if you can Google the issue unrelated to Payload. I am happy to continue to help here, but there is nothing actionable on Payload's side, so I will convert this to a discussion instead. Thank you! |
Beta Was this translation helpful? Give feedback.
-
Hi @jmikrut, thanks for your answer! I deployed this project to Railway with a Postgres database provided by Neon. One weird thing I've noticed is that this error happens both locally and in production every exact 5 minutes. Great to know that this is not Payload related. Switching over to Mongo which seems to work just fine, I wonder if this is related to either Railway or Neon then. |
Beta Was this translation helpful? Give feedback.
-
Thanks @jmikrut for the response. I got this using a Vercel hosted Postgres database (that uses neon as a provider), and locally using a local docker Postgres database. Currently I would probably also switch back to Mongo db if there are issues with the pg library. Usually after a few minutes the connection is lost and I have to restart the app. The error code |
Beta Was this translation helpful? Give feedback.
-
Was anyone able to solve this? Dealing with it right now in production (Railway) |
Beta Was this translation helpful? Give feedback.
-
I have this same issue while using AWS Aurora Postgres. I had to increase the idle timeout and get rid of the connection timeout (not ideal since there is no error when failing to connect, just hangs forever.) const postgresConfig: PostgresAdapterArgs = {
// pool config options are passed to node-postgres: https://node-postgres.com/apis/pool
pool: {
...connectionPoolOptions,
// node-postgres: max clients the pool should contain. default is 10.
max: 10,
/** number of milliseconds to wait before timing out when connecting a new client
* by default this is 0 which means no timeout
*/
connectionTimeoutMillis: 0,
/** number of milliseconds a client must sit idle in the pool and not be checked out
* before it is disconnected from the backend and discarded
* default is 10000 (10 seconds) - set to 0 to disable auto-disconnection of idle clients
*/
idleTimeoutMillis: 1000 * 60,
allowExitOnIdle: false
},
}; |
Beta Was this translation helpful? Give feedback.
-
Describe the Bug
Description:
When deploying on railway.app and also running locally, the application starts successfully and operates as expected initially. However, after a few minutes, it throws an "Unhandled 'error' event" and terminates the connection unexpectedly. Both instances of the issue seem to originate from the pg module, which is used for PostgreSQL interactions. So it happens both locally
Connection terminated unexpectedly,
and on railway.app (error code 57P01
). Sorry if these are two different issues, but both seem to originate frompg
?Error Details:
On railway.app (Node.js v18.17.1):
Locally I get
Observations:
The application works as intended initially, but the described issue arises only after a few minutes of operation.
This here is the error log on railway.app:
To Reproduce
My
payload.config.ts
Payload Version
^2.0.0
Adapters and Plugins
postgresAdapter, webpackBundler
Beta Was this translation helpful? Give feedback.
All reactions