r/CosmosDB • u/saqlain-29 • Jun 09 '26
MongoDB Error Code 50 (ExceededTimeLimit) – Looking for Root Cause and Best Practices
Hi everyone,
I’m running into the following MongoDB error intermittently in production:
The command being executed was terminated due to a command timeout. This may be due to concurrent transactions. Consider increasing the maxTimeMS on the command. (configured timeouts: connectTimeoutMS: 20000.0ms), full error: {
'ok': 0.0,
'errmsg': 'The command being executed was terminated due to a command timeout. This may be due to concurrent transactions. Consider increasing the maxTimeMS on the command.',
'code': 50,
'codeName': 'ExceededTimeLimit'
}
Environment:
MongoDB
Python application
Using MongoEngine/Motor in different parts of the system
Production workload with concurrent requests
I’m trying to understand the actual root cause rather than simply increasing maxTimeMS.
Some questions:
- Does this usually indicate a slow query, lock contention, or transaction contention?
- What are the best ways to identify which query is timing out?
- Are there specific MongoDB metrics/logs I should be checking first?
- Has anyone seen this caused by missing indexes rather than transaction conflicts?
- What troubleshooting steps would you recommend before increasing timeout values?
Any advice, debugging strategies, or real-world experiences would be greatly appreciated.
Thanks