Reputation: 61
i have client.js
and server.js
that already being set up and working perfectly. Only issue right now, is that i need to run client on 1 machine, server on another machine.
However, through the use of ethernet cable connection, only server.js
can be run. Client side is unable to connect even though both are able to ping each other's IP address.
Any solution I can look into? Much appreciated!
Do note that this will be run on virtual box ubuntu. For example, PC 1 will be running server.js
on virtualbox ubuntu, PC 2 will be running client.js
on virtual box ubuntu. However, after running server.js
, client.js
does not start/load.
Upvotes: 1
Views: 3047
Reputation: 111336
When you run client and server on the same machine then you can use localhost
hostname or an IP of 127.0.0.1 to connect via something that's called a loopback interface which is basically a virtual network card that routes everything back to itself.
When those are on different machines you need to use a real IP or hostname so you need to update your code or configuration to access the correct IP or port.
Also the port can be blocked by a firewall from external connections which is rarely done for localhost
. You need to also make sure that your port is not blocked.
Of course only a very general answer can be given to a question that doesn't include:
A general advice would be to:
Ping uses an ICMP protocol so it is possible to have a connection with ping but not with TCP which I assume you are using (but again, you didn't specify that). And of course you are never sure which machine you're pinging, only that you got an answer so it is theoretically possible that you are pinging yourself. You need to get the right IPs.
To know the IP address on your server see those answers:
Upvotes: 1