I've been working on my backend and everything was running smoothly until today. I installed a new library (`express-fileupload`), audited the packages, and added a new route and controller. Now my server is giving the following errors:
- Server + Socket running on port 5000
- MongoDB connection failed
- QuerySrv EREFUSED _mongodb._tcp.cluster0.yhaxy3o.mongodb.net
It keeps crashing and saying it's waiting for file changes. I haven't made any major changes other than those. Could the library installation be the cause? Also, I ran `npm audit` and found a couple of vulnerabilities, but I'm not sure if they're related to this issue.
1 Answer
It sounds like you might be having a MongoDB issue, but it could also be related to your local setup. I recommend checking if your database is running properly. Try running everything on localhost and see if that helps. If you stop the MongoDB server, you should get a clearer picture if your app isn't handling errors correctly and crashing as a result. Usually, if you see an ECNNREFUSED error, it might hint at DNS issues. Also, the npm audit isn’t likely the culprit here, but it might be good to fix those vulnerabilities when you can. Good luck!

If you're really stuck, try flushing your DNS cache. Sometimes that can help with connection issues!