I got the following error from the server today:
{ MongoTimeoutError: Server selection timed out after 30000 ms
at Timeout.setTimeout [as _onTimeout] (/home/ubuntu/xxx-v.1-backend/node_modules/mongoose/node_modules/mongodb/lib/core/sdam/topology.js:897:9)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)
name: 'MongoTimeoutError',
reason:
{ Error: getaddrinfo EAI_AGAIN xyz.mongodb.net xyz.mongodb.net:27017
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:56:26)
name: 'MongoNetworkError',
errorLabels: [ 'TransientTransactionError' ],
[Symbol(mongoErrorContextSymbol)]: {} },
[Symbol(mongoErrorContextSymbol)]: {} }
The server was running fine for more than a year, and all of a sudden, the server stopped working today. When I checked into the EC2 AWS Monitoring chart, it mentioned that CPU utilization is 100%. So, I rebooted the server from the EC2 console. Once the server restarted, when I looked into logs, I found the above error repeated multiple times. So, I assume that the NodeJS might have attempted to connect to Atlas multiple times and hence the CPU utilization being 100%.
When I looked up online for the EAI_AGAIN error, they mentioned that IP address might not be added to MongoDB Atlas or the name given is wrong. I checked both the suggestions, and the result is these are not the issue.
I do not know how to proceed further. Please assist with this issue.