Skip to content
Discussion options

You must be logged in to vote

If the MongoDB connection drops after inactivity, that's the driver's serverSelectionTimeoutMS kicking in. Payload just forwards whatever you put in connectOptions, so bump that timeout and enable autoReconnect:

// payload.config.js
module.exports = {
 mongo: {
 uri: process.env.MONGO_URI,
 options: {
 connectOptions: {
 serverSelectionTimeoutMS: 30000, // default is 30s
 autoReconnect: true,
 reconnectTries: Number.MAX_VALUE,
 reconnectInterval: 1000,
 },
 },
 },
};

Also make sure your MongoDB server isn't killing idle connections - set maxIdleTimeMS: 0 if you control the server, or use a connection pooler like ProxySQL/Atlas. If you're on a cloud provider, check their idle timeout setti…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@MurzNN
Comment options

@itxashancode
Comment options

Answer selected by MurzNN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants