I can not connect my application to cluster (please Help!)

I have another problem to connect my application with the cluster.

*my server.js
const express = require(“express”);

const mongoose = require(“mongoose”);

const cors = require(“cors”);

const { readdirSync } = require(“fs”);

const dotenv = require(“dotenv”);


const app = express();



readdirSync("./routes").map((r) => app.use("/", require("./routes/" + r)));



.connect(process.env.DATABASE_URL, {

useNewUrlParser: true,


.then(() => console.log(“database connected successfully”))

.catch((err) => console.log(“error connecting to mongodb”, err));

const PORT = process.env.PORT || 8000;

app.listen(PORT, () => {

console.log( server is running on port ${PORT}.. );


  • The terminal errors:

server is running on port 8000…
error connecting to mongodb MongoParseError: mongodb+srv URI cannot have port number
at new ConnectionString (C:\Users\vujim\OneDrive\Desktop\jvuwithjesus\backend\node_modules\mongodb-connection-string-url\lib\index.js:146:23)
at parseOptions (C:\Users\vujim\OneDrive\Desktop\jvuwithjesus\backend\node_modules\mongoose\node_modules\mongodb\lib\connection_string.js:213:17)
at new MongoClient (C:\Users\vujim\OneDrive
************Please help!!!

1 Like

Nice trick for the routes. Please add the .env -> DATABASE_URL . That has an error. You can remove any personal detail / pwd.