umutxyp / MusicBot

An enhanced music bot that is compatible with discord.js v14 and works with slash commands. Discord music bot codes that can be used on any server and are simple to install.
https://discord.gg/codes
987 stars 1.07k forks source link

mongodb error #109

Closed neylhates closed 1 year ago

neylhates commented 1 year ago

when i run the bot i have this error MongoDB Error: MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://www.mongodb.com/docs/atlas/security-whitelist/

WARN: It looks like you didn't write the mongodb url? If you do not enter a valid mongodb url in the config.js file, you will not be able to use the bot. but i wrote mongodb url correctly and yesterday it worked fine pls help me with this issue

MrDick004 commented 1 year ago

Hi, the same error happened to me for no apparent reason, the code never touched, however I solved it by deleting the "node_modules" folder and reinstalling everything with "npm install", the bot recognizes the MongoDB database again

neylhates commented 1 year ago

unfortunately it didnt worked. still have this error

MrDick004 commented 1 year ago

You're right, it only worked for me for 4 hours, but now it gives me the error again that it can't find the mongoDB database, I also tried putting the IP address back in "network access" of MongoDB but nothing, I can't figure out what it's due to, I also tried updating the dependencies but nothing changed. Even on the internet I can't find a solution.

neylhates commented 1 year ago

that is pretty upset. but thanks for help)

omgomghax commented 1 year ago

Check if this is ok

image

Also you can download mongodb Compass and paste in there the same connection link you pass to the bot's settings, you should be able to connect and see your databases if the link is correct.

MrDick004 commented 1 year ago

We already tried, and yes, everything is correct, as we mentioned it happened suddenly, nothing was touched, if the link was wrong it didn't work for me at all, instead it works for me almost intermittently, even updating the Mongoose dependency didn't fix anything, if I delete the "node_modules" folder and reinstall everything I get the bot working correctly for an hour and then the MongoDB error that can't find the database starts again, I don't know, maybe there is a bug in the dependencies or I really have no idea.

andybergner commented 1 year ago

if using a local database try changing the MongoDB URI from localhost to 127.0.0.1

omgomghax commented 1 year ago

i'd suggest you download and try mongodb Compass and see if you are getting disconnected from there as well. If the disconnection occurs in there as well, i think your problem is either with the IP getting blacklisted for some reason, or wrong cloud mongodb settings.

MrDick004 commented 1 year ago

Yes I tried with MongoDB compass and everything works correctly, it's just like the bot doesn't read the database link anymore, I also tried to remove the old database and create a new one, put the new link but nothing, trying with another bot the mongodb database works, that's why I can't figure out what it's due to.

RealAmethyst commented 1 year ago

You need to go on mongodb and ad the following IP address to your cluster: 0.0.0.0/0 after that the bot should work.

MrDick004 commented 1 year ago

I solved it by simply changing Hosting service, for some arcane mysterious reason replit after 2/3 hours that the bot is on sends the IP address blacklisted for mongoDB or vice versa.