Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

201
Views
Invalid scheme, expected connection string to start with "mongodb://" or "mongodb+srv://"

Invalid scheme, expected connection string to start with "mongodb://" or "mongodb+srv://"

I am using MongoDB atlas

Index.js

import bodyParser from "body-parser";
import mongoose from "mongoose";
import cors from "cors";
import postRoutes from "./Routes/posts.js";
import dotenv from "dotenv";

const app = express();
dotenv.config();

app.use(bodyParser.json({ limit: "50mb", extended: true }));
app.use(bodyParser.urlencoded({ limit: "50mb", extended: true }));
app.use(cors());

app.use("/posts", postRoutes);

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

mongoose
.connect(process.env.CONNECTION_URL, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => {
app.listen(PORT, console.log(Server is running on port ${PORT}));
})
.catch((err) => console.log(err.message));

.env file

CONNECTION_URL =
"mongodb+srv://<UserName>:<Password>@cluster0.v5qzigz.mongodb.net/?retryWrites=true&w=majority";

PORT = 4000;

it works fine if i do not use .env File. Process.env.CONNECTION_URL is not working ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

If the <Username> or <Password> includes those following characters, simply replace them.

: / ? # [ ] @

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!