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

325
Views
MongoError: database names cannot contain the character '/'

I am using moongoose npm package. When I try to connect with mongodb I am getting this error. Here is my code.

const mongoose = require("mongoose");

mongoose.connect("mongodb://127.0.0.1/27017/task-manager-api", {
  useNewUrlParser: true,
  useCreateIndex: true,
});

const User = mongoose.model("User", {
  name: {
    type: String,
  },
  age: {
    type: Number,
  },
});

const me = new User({
  name: "Sushant",
  age: 17,
});

me.save()
  .then(() => {
    console.log(me);
  })
  .catch((error) => {
    console.log("Error Spotted");
  });

MongoError: database names cannot contain the character '/'

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

0

Port number should be added with colon instead of forward slash

const mongoose = require("mongoose");
    
    mongoose.connect("mongodb://127.0.0.1:27017/task-manager-api", {
      useNewUrlParser: true,
      useCreateIndex: true,
    });
    
    const User = mongoose.model("User", {
      name: {
        type: String,
      },
      age: {
        type: Number,
      },
    });
    
    const me = new User({
      name: "Sushant",
      age: 17,
    });
    
    me.save()
      .then(() => {
        console.log(me);
      })
      .catch((error) => {
        console.log("Error Spotted");
      });
about 4 years ago · Juan Pablo Isaza Report

0

Your db URI contains a small typo mistake, as you wrote: mongodb://127.0.0.1/27017/task-manager-api

While it should be: mongodb://127.0.0.1:27017/task-manager-api

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!