vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Error connection mongoldb to viscose ECONNREFUSED 127.0.0.1:27017

Open fadelfffar opened this issue 3 years ago • 4 comments

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 Screen Shot 2022-04-30 at 10 32 05

fadelfffar avatar Apr 30 '22 03:04 fadelfffar

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 avatar May 03 '22 15:05 Anemy

@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

sadokmtir avatar May 23 '22 11:05 sadokmtir

Possible duplicate of https://github.com/mongodb-js/vscode/issues/408

Anemy avatar May 23 '22 12:05 Anemy

I ran the following:

docker run -it -p 27017:27017 mongo

image

I can confirm all the following work:

  • mongodb://0.0.0.0:27017/?readPreference=primary&ssl=false
  • mongodb://127.0.0.1:27017/?readPreference=primary&ssl=false
  • mongodb://localhost:27017/?readPreference=primary&ssl=false

SethFalco avatar May 31 '22 08:05 SethFalco

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.

Anemy avatar Nov 18 '22 13:11 Anemy