Question

I am using vagrant 1.6.2 on Windows 7, to run a Ubuntu 12.04 Virtual Machine.

I have enabled this on my Vagrantfile:

  config.vm.network :forwarded_port, guest: 3000, host: 3000
  config.vm.network :forwarded_port, guest: 27017, host: 27017, auto_correct: true
  config.vm.network :forwarded_port, guest: 27018, host: 27018, auto_correct: true
  config.vm.network :forwarded_port, guest: 9494, host: 9494

In the box, I can see that Mongodb is running,

~ $ mongo
MongoDB shell version: 2.0.4
connecting to: test
> exit
bye

However, from my Windows Host, I am unable to connect to the Mongodb instance, using localhost:27017.

The auto_correct: true was something I read on one of the forums, and tried it out.

On vagrant up this is what I get on the console:

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 3000 => 3000 (adapter 1)
    default: 27017 => 27017 (adapter 1)
    default: 27018 => 27018 (adapter 1)
    default: 9494 => 9494 (adapter 1)
    default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
GuestAdditions 4.3.12 running --- OK.

And if I do a rackup -p 3000, I am able to hit http://localhost:3000. Port 9494 also works, it is just the Mongo ports that aren't working.

And I had Mongo installed in my host (Windows), I uninstalled it, still the same problem.

Any hints?

Was it helpful?

Solution

It seems your Vagrant port forwarding is working fine. Your issue is probably because MongoDB is setup to only listen on 127.0.0.1. Check your bindip setting.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top