vscode
vscode copied to clipboard
Error connection mongoldb to viscose ECONNREFUSED 127.0.0.1:27017
Hi all,
OS: MacOS Monterey (12.3.1) VSCode: 1.66.2 MongoDB Extension: 0.9.2
I just had some issue connecting to a MongoDB server running inside Visual Code
I kept getting the following error: Unable to connect: getaddrinfo ECONNREFUSED 127.0.0.1:27017 mongoldb and i can't seem to figure out the solution for it

Hi @fadelfffar - could you tell us a little more about your MongoDB instance you are trying to connect to? Is it running on your machine on the port 27017? Is it bound to localhost or 127.0.0.1?
Are you able to connect to the same instance using the MongoDB Shell mongosh?
@Anemy I am also having the sam problem. I could connect with robo 3T. I have a Mongo server running in a docker compose:
mongo:
image: mongo:4.2.19-bionic
command: ["--replSet", "rs0"]
restart: unless-stopped
volumes:
- mongo-configdb:/data/configdb
- mongo-db:/data/db
ports:
- 27017:27017
Possible duplicate of https://github.com/mongodb-js/vscode/issues/408
I ran the following:
docker run -it -p 27017:27017 mongo

I can confirm all the following work:
mongodb://0.0.0.0:27017/?readPreference=primary&ssl=falsemongodb://127.0.0.1:27017/?readPreference=primary&ssl=falsemongodb://localhost:27017/?readPreference=primary&ssl=false
Going to close this issue, feel free to reopen if there's more information. Appreciate that you looked into it Seth! Thanks for checking out the extension and opening the issue.