question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MongooseServerSelectionError: connect ECONNREFUSED <not 127.0.0.1>

See original GitHub issue

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Mongoose version

6.7.2

Node.js version

18.12.1

MongoDB server version

5.0.13

Typescript version (if applicable)

No response

Description

I bought a mongodb server from my host and I have this error: MongooseServerSelectionError: connect ECONNREFUSED <the ip of the db with the port>

Steps to Reproduce

My uri to connect the db is: mongodb://admin:<the password>@<the ip of the db>:26041/Guilds?retryWrites=true&w=majority I connect the db like that: await mongoose.connect(config.MONGODB_GUILDS_URI). And if I connect with a mongodb db not a db of my host it work. and this is all of the error:

MongoServerError: Authentication failed.
    at Connection.onMessage (C:\Users\yassi.ABKAHOME\Documents\Bots-Discord\Bots-Test\UtilityBotTest\node_modules\mongodb\lib\cmap\connection.js:207:30)
    at MessageStream.<anonymous> (C:\Users\yassi.ABKAHOME\Documents\Bots-Discord\Bots-Test\UtilityBotTest\node_modules\mongodb\lib\cmap\connection.js:60:60)
    at MessageStream.emit (node:events:513:28)
    at processIncomingData (C:\Users\yassi.ABKAHOME\Documents\Bots-Discord\Bots-Test\UtilityBotTest\node_modules\mongodb\lib\cmap\message_stream.js:132:20)
    at MessageStream._write (C:\Users\yassi.ABKAHOME\Documents\Bots-Discord\Bots-Test\UtilityBotTest\node_modules\mongodb\lib\cmap\message_stream.js:33:9)
    at writeOrBuffer (node:internal/streams/writable:392:12)
    at _write (node:internal/streams/writable:333:10)
    at Writable.write (node:internal/streams/writable:337:10)
    at Socket.ondata (node:internal/streams/readable:766:22)
    at Socket.emit (node:events:513:28) {
  ok: 0,
  code: 18,
  codeName: 'AuthenticationFailed',
  connectionGeneration: 0,
  [Symbol(errorLabels)]: Set(2) { 'HandshakeError', 'ResetPool' }
}

I already change the password or other but nothing.

Expected Behavior

No response

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
Uzlopakcommented, Dec 7, 2022
0reactions
HamoBokercommented, Dec 8, 2022

I got same problem using node 18, i rolled back to 16 and everything works properly

Read more comments on GitHub >

github_iconTop Results From Across the Web

connect ECONNREFUSED 127.0.0.1:27017 - Ops and Admin
MongooseServerSelectionError : connect ECONNREFUSED 127.0.0.1:27017 ... but when connecting using shell or Compass there is no problem,.
Read more >
MongoError: connect ECONNREFUSED 127.0.0.1:27017
I had below error: Error: connect ECONNREFUSED 127.0.0.1:27017. In my case, this issue occurred since MongoDB is not installed at all.
Read more >
[Question] Connect fail MongooseServerSelectionError ...
But on the server, it keeps saying connect ECONNREFUSED 127.0.0.1:27017, I have researched for more than 4 hours but still no results.
Read more >
mongodb connect econnrefused 127.0.0.1 - You.com | The AI ...
This happened probably because the MongoDB service isn't started. Follow the below steps to start it: Go to Control Panel and click on...
Read more >
ECONNREFUSED 127.0.0.1:27017 | Resolve the connection ...
This video will demonstrate a way how you can resolve the error " connect ECONNREFUSED 127.0.0.1 :27017". So this is a connection issue...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found