-1

I have started my Node.js express server running on port 3000 and it works on my local computer the server is running on. Then I have forwarded the port 3000 to the IPv4 adress of my computer in my router but I still cannot connect to the server on other devices.

HAs it something to do with the protocol? Do you know why it doesn't work.

mittermor
  • 51
  • 7
  • How are you trying to connect to it on other devices? Can you connect to it on that device (via `localhost`/loopback)? – Jonathan Lam Aug 10 '19 at 18:58
  • yes: 10.0.0.14:3000 – mittermor Aug 10 '19 at 19:02
  • Not too familiar with router stuff, but is that the global IP address of your router? (Or are you just trying to connect within your LAN, in which case your IP address should likely be 192.168.x.x?) You should probably show your Node.js code and any errors you are getting (either from the client or the server, if any) – Jonathan Lam Aug 10 '19 at 19:05
  • no just in LAN, code follows – mittermor Aug 10 '19 at 19:14
  • to summarize: if have started a node.js server on my local machine and I want to access it over my network on other devices – mittermor Aug 10 '19 at 19:15
  • If it's just to other devices in LAN, find your *local IP address* (10.0.0.14 is likely not) on your computer (should start with 192.168, use `ip address show` in Linux) and don't worry about port forwarding. AFAIK other devices in the LAN should be able to access your device using the *local* IP address. – Jonathan Lam Aug 10 '19 at 19:16
  • Same question answered - https://stackoverflow.com/questions/30712141/connect-to-localhost3000-from-another-computer-expressjs-nodejs – Sushil Aug 10 '19 at 19:54

1 Answers1

0

To connect to a server on your own local LAN, you need the following things:

  1. The local IP address of the server. It would typically be something like 192.168.1.x, but in some cases it might be of the form 10.0.0.x.
  2. You need to make sure the computer the server itself is on does not have any local firewall that is blocking incoming http connections. On Windows 10, there is a local firewall that by default blocks incoming http requests so you would have to enable incoming http requests on the desired port in that firewall configuration.
  3. You can then connect to that server from somewhere else on your local network with a URL of the form http://192.168.1.x:3000/ where the 192.168.1.x is the actual local IP address of your server computer and the 3000 is the port the server is running on.
  4. You need to make sure your other devices are actually ON your local network. For example, if it's a phone, you need to make sure it's actually connected to your local network via WiFi and not connected to the visitor's connection that can only reach the internet, not your local network.
  5. You do not need to do any port forwarding in your router. That's something that would be done when connecting to your server from outside your network (like from the internet). I that case, you'd have to connect to your public IP address and have that safely port forwarded to your server. But, since you said you're trying to connect to the server from within your LAN, you don't need any port forwarding on your external firewall.
jfriend00
  • 683,504
  • 96
  • 985
  • 979