Access node.js/grunt server through localhost:port on virtual machine

o01 picture o01 · Oct 25, 2013 · Viewed 15.2k times · Source

I'm running a node.js server locally on port 9000 through Grunt. I also have a virtual machine running (vmware), but I can't access the node server through that. I've already configured the VM to access my Apache server on the host through localhost, but :9000 gives 'not found'.

Anyone know how to do this?

Answer

o01 picture o01 · Oct 25, 2013

Got it! In my project's Grunt.js file there was this setting:

grunt.initConfig({
    ...
    connect: {
      options: {
        port: 9000,
        // Change this to '0.0.0.0' to access the server from outside.
        hostname: 'localhost'
      },
    }
    ...
  });

All I had to do was to change localhost to 0.0.0.0 and restart grunt server.