4

I am trying to build a website for my college hence I chose mongodb as my database using NodeJS . It worked great in my local machine and on the Heroku. But now I am deploying it on the cPanel there is one issue that I am not able to connect to mongodb atlas and hence not able to get the data. From error logs I think the problem is with mongoose connect() but I am not sure. May be problem can be different also. I am attaching error logs and mongoose code from app.js file for better understanding of the problem. Please can you help in this.

mongoose.connect("mongodb+srv://usernmae:password@cluster0.1laezrl.mongodb.net/Yearbook10",
    {
      useNewUrlParser: true,
      useUnifiedTopology:true
    }
    ).then(()=>{
      console.log("Connected with the db")
    })

Nodejs in cPanel [1]: https://i.stack.imgur.com/RRdtb.jpg

Shriyash
  • 41
  • 4
  • check url, user name, password, firewall or settigs to allow network connection to database server if different IP. iN https://i.stack.imgur.com/RRdtb.jpg Looks like u have cropped a previous line with error, that might give clue. but if u r ok reaing json and dont need to write anything than go with ur read json from filesystem :) – tgkprog Jul 23 '22 at 20:35

0 Answers0