Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add localhost vs 127.0.0.1 info in FAQ and connections docs #13483

Closed
1 task done
nirvikpurkait opened this issue Jun 5, 2023 · 3 comments · Fixed by #13524
Closed
1 task done

Add localhost vs 127.0.0.1 info in FAQ and connections docs #13483

nirvikpurkait opened this issue Jun 5, 2023 · 3 comments · Fixed by #13524
Labels
docs This issue is due to a mistake or omission in the mongoosejs.com documentation
Milestone

Comments

@nirvikpurkait
Copy link

Prerequisites

  • I have written a descriptive issue title

Mongoose version

7.2.2

Node.js version

18.12.1

MongoDB version

6.0.4

Operating system

Windows

Operating system version (i.e. 20.04, 11.3, 10)

11

Issue

I can connect to mongoDB with 127.0.0.1:27017 and localhost:27017 both, with the help of mongoDB Compass, when I am trying to connect to the same with the help of mongoose, for localhost:27017 it is showing error message like, ECONNREFUSED ::1:27017, but in case if I try to connect with 127.0.0.1:27017, it connects.

N.B: I have checked my host mapping for my system, everything is mapped correctly.

@nirvikpurkait nirvikpurkait added help This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary help wanted labels Jun 5, 2023
@silentjohnny
Copy link

Node 18.x connects to IPv6 address ::1 instead of IPv4 127.0.0.1 when using localhost:27017.
Your MongoDB server needs to listen to IPv6 connections, please consider the following entry in your mongod.conf:

net:
  port: 27017
  bindIp: localhost
  ipv6: true

@IslandRhythms
Copy link
Collaborator

@vkarpov15 should we add this to the FAQ?

@nirvikpurkait
Copy link
Author

Node 18.x connects to IPv6 address ::1 instead of IPv4 127.0.0.1 when using localhost:27017. Your MongoDB server needs to listen to IPv6 connections, please consider the following entry in your mongod.conf:

net:
  port: 27017
  bindIp: localhost
  ipv6: true

It didn't worked initially, but after making the changes to config file, needed to restart the MongoDB server from services.

@vkarpov15 vkarpov15 reopened this Jun 8, 2023
@vkarpov15 vkarpov15 added this to the 7.2.4 milestone Jun 8, 2023
@vkarpov15 vkarpov15 added docs This issue is due to a mistake or omission in the mongoosejs.com documentation and removed help This issue can likely be resolved in GitHub issues. No bug fixes, features, or docs necessary help wanted labels Jun 8, 2023
@vkarpov15 vkarpov15 changed the title Why mongoose connecting to "127.0.0.1" but not connecting to "localhost" Add localhost vs 127.0.0.1 info in FAQ and connections docs Jun 8, 2023
@vkarpov15 vkarpov15 modified the milestones: 7.2.4, 7.3.1 Jun 12, 2023
vkarpov15 added a commit that referenced this issue Jun 19, 2023
docs(connections+faq): add info on localhost vs 127.0.0.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs This issue is due to a mistake or omission in the mongoosejs.com documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants