Issue mongodb connection when deploying sveltekit application to vercel

i’m using mongodb: ^4.13.0
here is the method i’m using to connect to mongodb when initializing the server

function connect() {
    try {
        if (!URI_DEV) throw new Error('URI is not added to your env variables');
        const uri = URI_DEV;
        const options = {
            useUnifiedTopology: true,
            useNewUrlParser: true
        const client = new MongoClient(uri, options);
        return client.connect();
    } catch (err) {
        throw new Error(err.message);

now when i’m checking the logs, they show me this error, and i can’t figure out why.

note that i’m using the same config and version of code and it works as expected.
can someone help me please to solve this problem. Thank you!

can somebody help me solving this issue please

Hi @gaming_state,

Based off the hostnames I presume this is an Atlas cluster. The error itself seems to be a generic connection failure one. Regarding integration with Vercel, could you check the following Integrate with Vercel documentation and more specifically perhaps the IP Access Lists in Atlas and IP Allow Lists in Vercel section?



thank you so much, it worked for me

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.