MongoDB errors

I wanted to update my worker removing the old deprecated MongoDB Atlas API, and I read that now Workers should support the MongoDB node.js driver, but I can't seam to make it work. Everything is working fine on my local machine, I set the compatibility flags to nodejs_compat and compatibility date to 2025-05-05, but when I publish the worker I keep getting errors like:
- MongoDB operation error: MongoServerSelectionError: [unenv] net.createConnection is not implemented yet!

- MongoDB operation error: Error: [unenv] dns.resolveSrv is not implemented yet!
- MongoDB operation error: MongoServerSelectionError: [unenv] net.createConnection is not implemented yet!

- MongoDB operation error: Error: [unenv] dns.resolveSrv is not implemented yet!
In my package.json the versions of wrangler and mongodb are respectively ^4.28.1 and ^6.18.0 Looking at this blog post https://alexbevi.com/blog/2025/03/25/cloudflare-workers-and-mongodb/ I cannot seam to find what I did wrong. Is this relative to the Free workers plan I'm using? A little bit of insight would be useful, thanks to who can help!
ALEX BEVILACQUA
Cloudflare Workers and MongoDB
Previously I wrote about Why Cloudflare Workers Don’t Work With MongoDB, but since then the Cloudflare team has done some great work to add support for the missing Node.js features MongoDB’s driver required to operate successfully from Cloudflare Workers:
4 Replies
Ashish Rawat
Ashish Rawat2w ago
you can take a look at this: https://github.com/eashish93/mongodb-with-do The idea is to use mongodb with DO. I've added full wrapper of mongo with DO there, supported all functions.
GitHub
GitHub - eashish93/mongodb-with-do: Fully working mongodb atlas wit...
Fully working mongodb atlas with cloudflare workers. Drop-in-replacement of original mongodb. - eashish93/mongodb-with-do
Ashish Rawat
Ashish Rawat2w ago
Using mongo with DO is not gonna work and will drop network connection in production. I'm using this way for all my production apps in workers
bunz
bunzOP2w ago
I know that to be efficient I have to use DO to store the MongoClient, but it should work without it, being incredible inefficient. The problem I have is that it doesn't work following the example in the blog post
Marvin Erkes
Marvin Erkes7d ago
Just came also here from reading the blog post. Currently Im using the Data API which will soon be out of service. Hoping for a official new solution for MongoDB here.

Did you find this page helpful?