I am getting this error const serverSelectionError = new ServerSelectionError();

The application successfully started on 27017
D:\web\web developement\Dance website pug\node_modules\mongoose\lib\connection.js:807

  const serverSelectionError = new ServerSelectionError();
                               ^

MongooseServerSelectionError: Invalid message size: 1347703880, max allowed: 67108864
    at NativeConnection.Connection.openUri (D:\web\web developement\Dance website pug\node_modules\mongoose\lib\connection.js:807:32)
    at D:\web\web developement\Dance website pug\node_modules\mongoose\lib\index.js:342:10
    at D:\web\web developement\Dance website pug\node_modules\mongoose\lib\helpers\promiseOrCallback.js:32:5
    at new Promise (<anonymous>)
    at promiseOrCallback (D:\web\web developement\Dance website pug\node_modules\mongoose\lib\helpers\promiseOrCallback.js:31:10)
    at Mongoose._promiseOrCallback (D:\web\web developement\Dance website pug\node_modules\mongoose\lib\index.js:1181:10)
    at Mongoose.connect (D:\web\web developement\Dance website pug\node_modules\mongoose\lib\index.js:341:20)
    at Object.<anonymous> (D:\web\web developement\Dance website pug\app.js:10:10)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10) {
  reason: TopologyDescription {
    type: 'Unknown',
    servers: Map(1) {
      '127.0.0.1:27017' => ServerDescription {
        _hostAddress: HostAddress { isIPv6: false, host: '127.0.0.1', port: 27017 },
        address: '127.0.0.1:27017',
        type: 'Unknown',
        hosts: [],
        passives: [],
        arbiters: [],
        tags: {},
        minWireVersion: 0,
        maxWireVersion: 0,
        roundTripTime: -1,
        lastUpdateTime: 2786731,
        lastWriteDate: 0,
        error: MongoParseError: Invalid message size: 1347703880, max allowed: 67108864
            at processIncomingData (D:\web\web developement\Dance website pug\node_modules\mongodb\lib\cmap\message_stream.js:91:18)
            at MessageStream._write (D:\web\web developement\Dance website pug\node_modules\mongodb\lib\cmap\message_stream.js:28:9)
            at writeOrBuffer (node:internal/streams/writable:389:12)
            at _write (node:internal/streams/writable:330:10)
            at MessageStream.Writable.write (node:internal/streams/writable:334:10)
            at Socket.ondata (node:internal/streams/readable:754:22)
            at Socket.emit (node:events:526:28)
            at addChunk (node:internal/streams/readable:315:12)
            at readableAddChunk (node:internal/streams/readable:289:9)
            at Socket.Readable.push (node:internal/streams/readable:228:10) {
          [Symbol(errorLabels)]: Set(0) {}
        }
      }
    },
    stale: false,
    compatible: true,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    logicalSessionTimeoutMinutes: undefined
  },
  code: undefined
4 Likes

did you get sollution to this bug?

This error is probably occur because the mongo dB services is not started yet what you have to do is
Go to control panel
Double click on services
then search for mongodb.exe and then click on start
its for window user
I hope it would be work.

3 Likes

/app/node_modules/mongoose/lib/connection.js:847
source_code-server-1 | const serverSelectionError = new ServerSelectionError();
source_code-server-1 | ^
source_code-server-1 |
source_code-server-1 | MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017

After running the mongodb service i got the above error for docker
docker-compose.yaml

version: “3.8”

services:

mongodb:

image: "mongo"

volumes:

  - data:/data/db

server:

build: ./server

ports:

  - "4000:4000"

volumes:

  - logs:/app/logs

  - ./server:/app

  - /app/node_modules

depends_on:

  - mongodb

client:

build: ./client

ports:

  - "3000:3000"

environment:

  - CHOKIDAR_USEPOLLING=true

volumes:

  - ./client/src:/app/src

stdin_open: true

tty: true

depends_on:

  - server

volumes:

data:

logs:

dockerfile

FROM node:18.8.0

WORKDIR /app

COPY package*.json /app/

RUN npm install

COPY . /app/

EXPOSE 4000

CMD [ “npm”, “start”]

Please help me.

Hey I think your problem is that you don’t have mongodb installed on your computer. Once you download it you can change

mongoose.connect('mongodb://localhost:27017/blog')

to

mongoose.connect('mongodb://127.0.0.1/blog')
3 Likes

Thankyou this saved me haha

Ok, changing the URI worked but why?!?! :laughing:

Ok I’m using mongoose and found out why:

from MS Edge

this worked for me. thank you

thank u, it was pain in my head

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.