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?
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
.
You have to use your local IP address.
I am on a mac so I go to System Preferences > Network > "Advanced" tab > TCP/IP > IPv4 Address: (ex 10.0.0.3)
Then point your browser to that address using your port number (ex :9000) or whatever you have setup.
Ex: http://10.0.0.3:9000
I don't think this is very secure for your local box so make sure to kill the server when you are finished working. Hope this helps.