Search code examples
node.jsmongodbexpressmongoosevercel

(Vercel/ MongoDB): Failed to connect with the database: querySrv ETIMEOUT


I can run my ExpressJS API locally using the "vercel dev" command, but when I try to deploy it ("vercel" command) I get this error: "Failed to connect with the database: querySrv ETIMEOUT _mongodb._tcp.cluster0.ibujag1.mongodb.net"

I am using the MONGODB_URI automatically created by the MongoDB integration with Vercel. Vercel automatically created a user in MongoDB's Database Access and I already added the ip 0.0.0.0/0 to the Network Access.

Here is my code: https://github.com/xdanrj/stancapapi

The MONGODB_URI looks like: mongodb+srv://vercel-admin-user:[email protected]/Stancap?retryWrites=true&w=majority


Solution

  • I used Docker to create a container of the app and it worked.