I have a pretty straight-forward question. I made a web game with NodeJS, and I can successfully play it by myself with multiple browser windows open side-by-side; however, I'd like to know if it's possible for other local machines to be able to access and play the game with me too.
I naively tried using this url: my-ip-address:8000
and it won't work.
If you are using a router then:
Replace
server.listen(yourport, 'localhost');
withserver.listen(yourport, 'your ipv4 address');
in my machine it is
Make sure your port is forwarded to your ipv4 address.
You can get your IP Address by typing
ipconfig
in cmd if your Windows user else you can useifconfig
.By default node will run on every IP address exposed by the host on which it runs. You don't need to do anything special. You already knew the server runs on a particular port. You can prove this, by using that IP address on a browser on that machine:
If that didn't work, you might have your IP address wrong.
I had the same question and solved the problem. In my case, the Windows Firewall (not the router) was blocking the V8 machine I/O on the hosting machine.
My guess is that "Evented I/O for V8 Javascript" is the I/O process that node.js communicates to outside world and we need to free it before it can send packets outside of the local computer. After enabling this program to communicate over Windows firewall, I could use any port numbers to listen.
Faced similar issue with my Angular Node Server(v6.10.3) which set up in WIndows 10.
http://localhost:4201
worked fine in localhost. Buthttp://{ipaddress}:4201
not working in other machines in local network.For this I updated the
ng serve
like thisAfter doing this modification able to access my application in other machines in network bt calling this url
Make sure the server is running, either by using 'npm start', or 'nodemon' in the command line window.