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

232
Views
I deployed my app on heroku and I am getting this error on running heroku logs tail "Error connecting to the database"

I am getting the error because the url in mongoose.connect function is incorrect. What should I put in as the url to connect to the database.

var mongoose = require("mongoose");

mongoose.connect("mongodb://localhost/Blog");

var database = mongoose.connection;

database.on(
  "error",
  console.error.bind(console, "Error connecting to the database")
);

database.once("open", () =>
  console.log("Successfully connected to the database")
);

module.exports = database;
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Is a Mongo Database service running on that Heroku machine so that you can access it via localhost? If not, you should install it, otherwise you cannot connect to an non-existent service. Then, check on what port it is running, it is usually localhost:27017.

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!