Quantcast
Channel: Active questions tagged mongodb-atlas - Stack Overflow
Viewing all articles
Browse latest Browse all 219

strugling to connect express app to mongodb atlas

$
0
0

iam strugling to connect my simple server to mongodb using atlas. i have created a new project and database with cluster, they provide a connect string i use exactly like they say. but i get this error after sometime. here is my code

import mongoose from "mongoose";mongoose  .connect("mongodb+srv://carproject:carproject1@car-project.u4g8sog.mongodb.net/?retryWrites=true&w=majority&appName=car-project"  )  .then(() => {    console.log("connected");  }).catch(err=>   {    console.log(err)  }    )const app = express();app.get("/", (req, res) => {  res.send("Hello, World!!!");});const PORT = process.env.PORT || 3000;app.listen(PORT, () => {  console.log(`Server is running on port ${PORT}`);});```` and i get this error in the console after few minutes `Error: queryTxt ETIMEOUT car-project.u4g8sog.mongodb.net    at QueryReqWrap.onresolve [as oncomplete] (node:internal/dns/promises:251:17) {  errno: undefined,  code: 'ETIMEOUT',  syscall: 'queryTxt',  hostname: 'car-project.u4g8sog.mongodb.net'}````

Viewing all articles
Browse latest Browse all 219

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>