Closed joezappie closed 8 months ago
Hi, thanks for the detailed report. Could you try changing "localhost" in the URI to "127.0.0.1"?
I can't reproduce your error for now. I have also made some minor changes in the system that will be available in the next patch.
I tried it with 127.0.0.1 yesterday but I got the same error. I'm working on setting up a sample vscode devcontainer that I can provide you with so maybe you can reproduce it.
Could you please confirm this is still an issue with v1.13 ?
Sorry got distracted on a totally different project. I'll try it out tonight.
After upgrading to 1.13 I'm still getting an MongoServerSelectionError: connect ECONNREFUSED ::1:27017
error despite Compass, Studio 3T and QueryAssist being able to connect with the same URI
@tothradoslav I'm still having issues with this even in 1.13.4.
I created a sample VS Code DevContainer that spins up a local mongo replica set: https://github.com/jrj2211/mingo-local-db-issue
Enviroment: VScode Docker Desktop
Steps to use:
clone
Dev Containers: Clone repository in Container Volume
Try to connect to mingo with mongodb://localhost:27017
or mongodb://127.0.0.1:27017/
and see that you get an connection refused error message. Works with Mongo Compass and every other mongo client.
I did also just test on my laptop to make sure it wasn't something weird with my desktop. Got the same connection refused in mingo but compass connected fine. I'd love to be able to uninstall all the other mongo clients I have and just use mingo because its so much better!
Looking at the logs from docker, its accepting the connection and then disconnecting:
2023-11-09 16:08:16 {"t":{"$date":"2023-11-09T21:08:16.661+00:00"},"s":"I", "c":"NETWORK", "id":22943, "ctx":"listener","msg":"Connection accepted","attr":{"remote":"127.0.0.1:46360","uuid":"26aeb801-058e-4dae-91b4-42f35178738b","connectionId":23,"connectionCount":6}}
2023-11-09 16:08:16 {"t":{"$date":"2023-11-09T21:08:16.662+00:00"},"s":"I", "c":"NETWORK", "id":51800, "ctx":"conn23","msg":"client metadata","attr":{"remote":"127.0.0.1:46360","client":"conn23","doc":{"application":{"name":"mingo"},"driver":{"name":"nodejs","version":"6.1.0"},"platform":"Node.js v18.16.1, LE","os":{"name":"win32","architecture":"x64","version":"10.0.19045","type":"Windows_NT"}}}}
2023-11-09 16:08:16 {"t":{"$date":"2023-11-09T21:08:16.671+00:00"},"s":"I", "c":"NETWORK", "id":22944, "ctx":"conn23","msg":"Connection ended","attr":{"remote":"127.0.0.1:46360","uuid":"26aeb801-058e-4dae-91b4-42f35178738b","connectionId":23,"connectionCount":5}}
@tothradoslav I spent a few hours on this today and got Mingo to connect, though I still don't have a reason why
Tried running it directly in docker (no vs devcontainer) and it connected fine:
docker run --rm -d -p 27017:27017 --name mongo mongo:6.0.5 --replSet=dbrs && timeout /t 5 && docker exec mongo mongosh --quiet --eval "rs.initiate({_id:'dbrs', version:1, members:[ { _id:0, host :'localhost:27017' }]});"
Thought it might be because I upgraded from mongo:5.0.9
to mongo:6.0.5
but trying the previous command with 5.0.9
works as well.
After more playing around I changed my devcontainer docker compose script to this:
The healthcheck to initialize the replicaset doesn't work with these changes for some weird reason so I manually ran it:
exec mongo mongosh --quiet --eval "rs.initiate({_id: 'dbrs', version:1, members:[{_id:0, host:'localhost:27017'}]});"
After that mingo was able to connect!
None of my changes feel meaningful, but something in there is what causes it not to work. The biggest change I think is switching from using entrypoint
to command
. My test repo posted earlier still has the old code where Mingo will not connect but compass will. With my old code I did verify by checking the logs the healthcheck works for initializing the replicasets. If it didnt, compass also would not connect.
I've since switched to bitnami/mongo image as it handles setting up replicasets much easier and that all works. For some reason, something with the replica sets causes this. I'll consider my issue resolved, but it still might be worth looking into as Studio 3T, query assist, compass could all connect while Mingo failed and someone else might run into this in the future and because I still don't have a concrete reason why these changes makes it work.
hi @jrj2211 , thanks for the detailed report. I will try to go through the problem again using the older and newer version. If you could send me the old and new version of your devcontainer docker compose scripts, that would really be helpful.
Taking a break clearly helps because I just realized there's a MASSIVE difference between those two compose scripts I posted earlier. The one that works with Mingo forwards port 27017, which should have been obvious to me and is the key to this.
I now know this is just a weird use case with how Docker handles networking between the containers and the host and less of an issue with Mingo. I'm good to close this issue as I feel I have closure lol.
It is still odd that somehow without the ports forwarded Compass can resolve it but Mingo can't. IF you're intrigued into still looking into it I have two repos for it:
Non-working - Mongo Compass, Studio 3T can connect but Mingo cant https://github.com/jrj2211/mingo-local-db-issue
Working - Mingo can connect as ports are forwarded https://github.com/jrj2211/mingo-local-db-issue-working
Only difference is adding the port forwarding. You can clone the repo by clicking the VS code button in the readme, and you can only have one running at a time.
Again, you probably have better things to do with your time so feel free to close this issue.
I just started the docker at https://github.com/jrj2211/mingo-local-db-issue which didn't work for you and did not work for me either. However, I could not connect to this instance of mongodb with mingo, nor compass or studio 3t.
Then I added port mappings into the yml file, such as:
ports:
- "27017:27017"
And then it started working fine in both mingo and compass. Could it be that you might have some mapping set up in compass or on you system? Because I could not connect to that server with compass until I configured the port mappings.
Interesting that it didn't work in Compass for you. It's very possible I did something weird as I know at one point I was messing around with my host file for Mongo in Docker when I first started learning Docker.
Closing this issue as port forwarding is the answer. Thanks for your help and loving Mingo!
Describe the bug
I have a VSCode devcontainer project that starts up a mongodb replica server. Mongo Compass and Studio 3T both can connect via the URI:
Mingo however gives me an ECONNREFUSED error:
Really looking forward to getting this to work so I can uninstall compass and Studio 3T off my computer. Loving the cleanness of the UI and how easy it makes it to migrate data between collections, databases and other connections! Finally a good modern mongo client.
Setup
I create the mongo DB via docker-compose in WSL:
Its started as a 1 node replica set to be able to use transactions in dev. There are no mongo users, admin DB is empty.
Does compass and 3T just add some required default parameter that I'm missing in Mingo? I tried adding
replicaSet=
parameter, and my default DB but cannot get it to connect. Works find connecting to my Atlas and Digital Ocean connections, just not my dev environment.Screenshots
Studio 3T![image](https://user-images.githubusercontent.com/6005836/233734353-3d901520-d195-4336-a6eb-42079301ce82.png)
Compass![image](https://user-images.githubusercontent.com/6005836/233734406-f7500286-f233-44b1-8b87-6514a0bf0858.png)
Mingo![image](https://user-images.githubusercontent.com/6005836/233734465-bf338d08-ff4b-48bf-9de4-b0619e22a14d.png)
Desktop (please complete the following information):