MongoTopologyClosedError: Topology is closed


When I am trying to connect to the MongoDB database it shows this error. Here I have submitted my index.js code and submitted also error reason before console.log(err) and after console.log(err). Can anyone suggest some techniques to solve this type of error?

I am using a Wi-Fi (ISP) connection for browsing the internet and I had also tried mobile data but it cannot solve it.

Hello @Md_Shihab, you can refer these MongoDB NodeJS Driver examples and try to use them as a guide for your coding - like, connecting to the database and performing some operations on the database.

if the function is asynchronous check if you’ve used the await method before the appropriate function

1 Like