# Vidly-API-Node seed issues 'new MongoNetworkError'

**URL:** <https://forum.codewithmosh.com/t/vidly-api-node-seed-issues-new-mongonetworkerror/13285>\
**Category:** React\
**Created:** [June 25, 2022, 8:27am UTC](https://forum.codewithmosh.com/t/vidly-api-node-seed-issues-new-mongonetworkerror/13285 "2022-06-25T08:27:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Defterniko](https://avatars.discourse-cdn.com/v4/letter/d/d26b3c/32.png) [@Defterniko](https://forum.codewithmosh.com/u/Defterniko)\
**Post date:** [June 25, 2022, 8:27am UTC](https://forum.codewithmosh.com/t/vidly-api-node-seed-issues-new-mongonetworkerror/13285/1 "2022-06-25T08:27:03Z")

</div>

Hi all,

I’m currently working through the React course and I’m at the point of setting up the Node backend. I ran into the same issues that others have previously mentioned to do with Bcrypt and luckily I have resolved that.

However, I now run into an issue when running node seed.js. I get this following error and don’t know what to do to resolve it.

```auto
/workspaces/React/vidly-api-node/node_modules/mongodb-core/lib/topologies/server.js:503
          new MongoNetworkError(
          ^
MongoNetworkError: failed to connect to server [localhost:27017] on first connect [Error: connect ECONNREFUSED 127.0.0.1:27017
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1157:16) {
  name: 'MongoNetworkError'
}]
    at Pool.<anonymous> (/workspaces/React/vidly-api-node/node_modules/mongodb-core/lib/topologies/server.js:503:11)
    at Pool.emit (node:events:526:28)
    at Connection.<anonymous> (/workspaces/React/vidly-api-node/node_modules/mongodb-core/lib/connection/pool.js:326:12)
    at Object.onceWrapper (node:events:646:26)
    at Connection.emit (node:events:526:28)
    at Socket.<anonymous> (/workspaces/React/vidly-api-node/node_modules/mongodb-core/lib/connection/connection.js:245:50)
    at Object.onceWrapper (node:events:646:26)
    at Socket.emit (node:events:526:28)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

```

I then update the seed.js file’s seed method to connect to mongoose like so:

```auto
 await mongoose.connect(config.get("db"), {
    useNewUrlParser: true,
    useUnifiedTopology: true,
  });

```

Which the just creates a server error, as such:

```auto
const serverSelectionError = new ServerSelectionError();
                               ^

MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
    at NativeConnection.Connection.openUri (/workspaces/React/vidly-api-node/node_modules/mongoose/lib/connection.js:828:32)
    at Mongoose.connect (/workspaces/React/vidly-api-node/node_modules/mongoose/lib/index.js:335:15)
    at seed (/workspaces/React/vidly-api-node/seed.js:42:18)
    at Object.<anonymous> (/workspaces/React/vidly-api-node/seed.js:64:1)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47 {
  reason: TopologyDescription {
    type: 'Single',
    setName: null,
    maxSetVersion: null,
    maxElectionId: null,
    servers: Map(1) {
      'localhost:27017' => ServerDescription {
        address: 'localhost:27017',
        error: Error: connect ECONNREFUSED 127.0.0.1:27017
            at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1157:16) {
          name: 'MongoNetworkError'
        },
        roundTripTime: -1,
        lastUpdateTime: 2956358,
        lastWriteDate: null,
        opTime: null,
        type: 'Unknown',
        minWireVersion: 0,
        maxWireVersion: 0,
        hosts: [],
        passives: [],
        arbiters: [],
        tags: []
      }
    },
    stale: false,
    compatible: true,
    compatibilityError: null,
    logicalSessionTimeoutMinutes: null,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    commonWireVersion: null
  }
}

```

Any ideas?

---

<div class="post-metadata">

**Author:** ![Defterniko](https://avatars.discourse-cdn.com/v4/letter/d/d26b3c/32.png) [@Defterniko](https://forum.codewithmosh.com/u/Defterniko)\
**Post date:** [June 25, 2022, 9:34am UTC](https://forum.codewithmosh.com/t/vidly-api-node-seed-issues-new-mongonetworkerror/13285/2 "2022-06-25T09:34:02Z")

</div>

After much searching around, I found I needed to update the ‘default.json’ file in the config folder to match the port. As well as remove the ‘localhost’ part of the db string and replace it with: “127.0.0.1”.

Rookie mistake.

---

<div class="post-metadata">

**Author:** ![Bravono](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/bravono/32/3426_2.png) [@Bravono](https://forum.codewithmosh.com/u/Bravono)\
**Post date:** [March 2, 2023, 11:59am UTC](https://forum.codewithmosh.com/t/vidly-api-node-seed-issues-new-mongonetworkerror/13285/3 "2023-03-02T11:59:46Z")

</div>

Hi, would you like to show exactly what your default.json looks like exactly?
