Connect with MongoDB Compass to MongoDB server running using vagrant

It was not mentioned in lessons, so if you are interested, here is how to do that.

While your vagrant box is booting, you can see these lines:

==> m312: Forwarding ports…
m312: 30000 (guest) => 30000 (host) (adapter 1)
m312: 30001 (guest) => 30001 (host) (adapter 1)
m312: 30002 (guest) => 30002 (host) (adapter 1)

This means that ports 30000, 30001 and 30002 on your vagrant box will be accessible on your local machine. This means that if you are running MongoDB server on 30000, 30001 and 30002, you can reach the server on your local machine, including using MongoDB compass by specifying correct port:

3 Likes

@ edvjur

Thanks for pointing that out. Good luck.