MongoError: Topology is closed, please connect
See original GitHub issueHi, I am receiving this error when inserting a documentMongoError: Topology is closed, please connect
This is my code
const monk = require('monk')
const url = 'mongodb+srv://user:pass@cluster0-hcldh.mongodb.net/sample_airbnb';
const db = monk(url);
const lar = db.get('listingsAndReviews')
lar.insert({name: "Lovely Loft", summary: "A charming loft in Paris", bedrooms: 1, bathrooms: 1})
// db.then(() => {
// console.log('Connected correctly to server') //this works
// }).catch((error) =>{
// console.log(error);
// })
What have I done wrong?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:9
- Comments:13
Top Results From Across the Web
MongoError: Topology is closed, please connect despite ...
I am writing a web application that uses asynchronous database requests as a part of the api. Currently, I have an async express...
Read more >MongoTopologyClosedError: Topology is closed - MongoDB
Help When I am trying to connect to the MongoDB database it shows this error. Here I have submitted my index.js code and...
Read more >MongoError: Topology is closed, please connect (client.close ...
Coding example for the question MongoError: Topology is closed, please connect (client.close and client.connect issue)-mongodb.
Read more >[NODE-2544] Can't reuse mongo client after close
const client = new MongoClient(url, { useUnifiedTopology: true });. await client.connect ... MongoError: Topology is closed, please connect.
Read more >MongoTopologyClosedError | mongodb
An error generated when an attempt is made to operate on a dropped, or otherwise unavailable, database. Hierarchy. MongoAPIError. MongoTopologyClosedError ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Getting the same thing when trying to preform:
MongoClient.close
returns a promise and needs to be waited on to work without errors or warnings. A new instance ofMongoClient
needs to be allocated either via staticMongoClient.connect
or via instanceconnect
, like this.