Error using Mongoose [connect ECONNREFUSED]

I’m trying to connect the databse (I’m new at this) and worked once but now won’t work again, some videos say that you have to start MongoDB service, but they do it from their Windows, how can I start it on glitch?

The manager module

const mongoose = require("mongoose");

const Mongo = {
  Con: async function() {
    await mongoose.connect("mongodb://localhost/Profiles", {
      useNewUrlParser: true,
      useUnifiedTopology: true
    return mongoose;
  Profile: mongoose.model(
      Id: String,
      Name: String,
      Lvl: Number,
      Coins: Number,
      XP: Number

module.exports = Mongo;

Test command to try it

const mongo = require("../mongo.js");

module.exports = {
  name: "test",
  async execute(Discord, client, message, args) {
    let con = await mongo.Con();
    try {
      let profile = new mongo.Profile({
        Lvl: 5,
        Coins: 100,
        XP: 400
        .then(r => + "R"))
        .catch(e => console.error(e + "E"));
    } finally {

And the result on console is this one (Personalized errors)

MongooseServerSelectionError in test command: connect ECONNREFUSED

Hello. It looks like you’re trying to Connect mongodb to Localhost.

Do you have mongodb server?
If no, go create one project then on your client, Target it to your Mongodb server URL.

1 Like

I don’t

And I don’t have any idea how to do that, do you have a link to a tutorial or can at least briefly explain it?

I don’t recommend setting up a mongo server on Glitch, instead, you should look into something like MongoDB atlas.


Yeah, it’s not recommended at Glitch.

You can try these database manager as your mongodb alternative:

You can go to

No, no offense, but don’t use these as MongoDB alternatives.

Once you sign up at, you can create a cluster on their free tier. Once you’ve done that, they’ll give you a url to connect to the cluster, which you can plug into mongoose.connect('that url here'); and data will get stored in that cluster.

I’d suggest searching for tutorials and videos about using Mongoose with MognoDB Atlas (I had found one really nice video, but now I can’t seem to find it).


If you already have a mongodb, you might have to whitelist to allow connections from anywhere.


The reason that is: it’s because that Glitch Project’s IPs switches a few times