skip to Main Content

I’m running api that is integrated with mongodb, the API is hosted on cpanel for a while. It worked perfectly since 1 week when it started showing some strange connection error, while in the development environment everything is running fine.Here is the error I got on cpanel.

App 3765874 output:     at Mongoose.connect (/home/danai/nodevenv/danai-api/12/lib/node_modules/mongoose/lib/index.js:376:20)
App 3765874 output:     at Mongoose._promiseOrCallback (/home/danai/nodevenv/danai-api/12/lib/node_modules/mongoose/lib/index.js:1220:10)
App 3765874 output:     at promiseOrCallback (/home/danai/nodevenv/danai-api/12/lib/node_modules/mongoose/lib/helpers/promiseOrCallback.js:31:10)
App 3765874 output:     at /home/danai/nodevenv/danai-api/12/lib/node_modules/mongoose/lib/helpers/promiseOrCallback.js:32:5
App 3765874 output:     at /home/danai/nodevenv/danai-api/12/lib/node_modules/mongoose/lib/index.js:377:10
App 3765874 output:     at NativeConnection.Connection.openUri (/home/danai/nodevenv/danai-api/12/lib/node_modules/mongoose/lib/connection.js:819:32)

2

Answers


  1. It seems like MongoDB have an "allowed ips" list https://www.mongodb.com/docs/atlas/security/ip-access-list/
    If you set it up in your dev environment, and then moved it without adding what ips should be allowed to connect to it in the prod environment, that might cause an issue.

    Login or Signup to reply.
  2. You have to white list you cpanel server ip in mongodb atlas
    https://www.mongodb.com/docs/atlas/security/ip-access-list/

    in you mongodb atlas Dashboard
    in security tab you will find network tab
    in this you have to ip address of you cpanel server to whitelist it
    checkout this images
    https://phpout.com/wp-content/uploads/2023/07/Mpgzq.png

    https://phpout.com/wp-content/uploads/2023/07/Jdgdi.png

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search