Hey @Johan_Maupetit,
Welcome to the MongoDB Community forums!
Based on the error logs shared, it appears that your connection is experiencing a timeout. I suspect that it may be occurring either due to network errors or the PRIMARY is getting re-elected in your configuration, causing it to lose connection. I would suggest you implement a try-catch behavior in the application code, allowing it to easily switch to the new PRIMARY node.
If the issue still persists after verifying the above, it would be helpful to share the code snippet of your connection code and the logs from the MongoDB server of the same timeframe. This will allow us to assist you better.
Furthermore, please provide the exact versions of MongoDB, Mongoose, and the Node.js driver you are using.
Best,
Kushagra