NodeJS works only on my network - node.js

I have my nodejs server app running on my windows 10 machine which uses my home internet connection.
When I am connected with my phone to my home internet and write the IPv4 Address and port I get a response and my web page loads, but when I use a different internet connection it doesn't load.
I turned off the firewall, tried a lot of different ports but nothing worked.
I tried app.listen(8000) or app.listen(8000, "0.0.0.0") but both didnt fix the problem.
Any ideas what might be the problem?

OK I found out how to do this, my port forwarding was not configured correctly.
Here is how I solved it in case someone has the same problem:
Connected to my router (in cmd write ipconfig, copy the Default Gateway ip and paste in browser).
Clicked port forwarding (each router have it in different place), set external IP to 0.0.0.0 and my app port, and set internal ip to my computer ip (you can just write "what is my ip" in google) and same app port.
I hope it will help someone.

Related

Virtual server port forwarding

local connection
Nmap scan of public ip address
Open Port Check Tool result
Virtual server configuration
I have a linux machine on a dekstop with arch linux installed that I use as a server running Apache2 (it works perfectly fine locally), and I want to use port forwarding to access it from the public ip address.
I tried using the router's virtual server service, so I redirected my local to port 2112 of my public ip address, I already used http://www.portchecktool.com/ to scan the port, and it says that the port is open whenever I enable it (I tried changing the port number many times, 443, 22, 5555...). But when I try to connect, it says 'Unable to connect'.
(Even thought the port scanner tool says the port is open on my public ip, when I scan my router's port with nmap it says it's closed)
I know I didn't provide many details, but is there something that I'm missing ?
EDIT:
It seems that the problem only occurs locally, which is why the nmap and port checker results are different, I asked a friend of mine to connect to my public ip address on port 2112, and he told me that it's working fine, and that he could see the page, why does this problem occur ? Why can I access it from outside LAN but not from the inside ?
There are a few parts to this answer:
To keep it simple I am going to assume a few things as you did not specify too many things.
What you have
Ubuntu Server VM running on your Windows machine
What you are trying to do
Connect to the VM (running Apache2) to view a website on the server via your public IP
If either of these are incorrect let me know
Ensure you first have port-fording setup on your main router to go to your Windows machine local IP. Open the correct port that your Appache2 server is running on.
Ensure you have opened the correct port on your windows machine firewall to allow that inbound traffic
Change the network settings for your VM to bridge the connection

how to connect to a server running on computer using computer's IP address?

I am working on IOT project in which I have to change some variables(fans speed, lights, etc). So just as a starter, I created a node.js server and tried to send requests to the server through a local network using local IP as
http://localhost:7000/users=mandar?lights=OFF
or
http://192.168.43.248:7000/users=mandar?lights=OFF
and it works fine.
Now I want to do the same over the internet. So I got Computer's IP address from https://www.google.co.in/search?q=myip and tried to send a request to the following URL:
http://(IP_address):7000/users=mandar?lights=OFF
This time it keeps on loading and finally shows this site can't be loaded.
So what is the right way to connect to the server through the internet?
Thank you.
You have to do port forwarding.
The IP address you get from the google search is the out-facing IP address of your router. However, your router knows your computer by your local IP address (i.e. 192.168.x.y).
You have to configure your router to send packets coming from internet destined to port 7000(or any other port) to your computer's port 7000.
Check your router's documentation on port forwarding. Likely there is a settings page on the web interface of your router that you can do the desired port forwarding. After configuring the router, there are several tools online to test if the port forwarding is actually working. I suggest you use one of those tools to verify the configuration before testing with your project.
You also might want to check if your router has a firewall. You can add an exception to the firewall such that a specific port number is reachable from the internet.

how to view my website from anywhere which is running in my laptop at home.?

Things I did so far.
my website is running on port 80.
had opened my port 80 with the help of VPN book. confirmed with canyouseeme.org.
Created an account in noip.com. Created a hostname.
using the AsusZenfone3 mobile phone and airtel 4g mobile data. getting internet to my laptop via Hotspot/Tethering using wifi from phone and laptop.
had downloaded DUC from noip and it is running fine.
had configured a device in noip.com for my host like below,
- hostname
router brand as Asus(I don't use any router/ I don't know what router is used)
-software/device as HTTP
Is there any computer running on your network? Yes
downloaded Duc
port 80 check success
my host has been successfully configured.
I also added rules to my firewall to enable TCP and UDP 80 port access.
But still, I am not able to access my website.
I tried calling my website from the proxy server, I get an empty result from the server.
Cannot say for certain, but it sounds like you opened port 80 on your router but likely did not forward that port to an address on your local LAN.
Somewhere in your router config you should be able to find a port forward option. So any traffic received on that port would need to be forwarded to the local IP of the computer running the webserver.
Problem
Your port is not forwarded through your gateway connection.
Solution
Fwd Port Forwarding app for Android phone

Port forward not working to set a local web server

I have just created a simple web server using node server and it's running fine. I can access it from the same PC by going to address http://127.0.0.1:1337.
Now I want to access that web server from my WAN IP. I got my my using whatismyip and got something like 110.36.xxx.xxx.
When I tried http://110.36.xxx.xxx:1337, I got:
Firefox can't establish a connection to the server at 110.36.xxx.xxx:1337.
Here is the screenshot how I created the port forwarding in my router:
What's wrong here?
Localhost is only accessible from the same pc. You have to launch your webserver either on address 0.0.0.0 (it will be available on all network interfaces) or 192.186.0.5 so that it is accessible from your wan interface

Port Forwarding on website

I'm noob in this field, so please help me understand this:
I have my web application launched on port 8080. I thought that if i forward port 8080 and enter from web browser: myexternalipadress:8080/Index.html it should open my website. please tell me why i'm wrong
Ahh, hosting a website from your house is a fun thing indeed. In my experience, here is how I approach trouble shooting.
1.Making sure your server is configured properly.
Launch the server application
If your client and server are the same machine, make sure you can reach the server on localhost
Access the server from a different computer on your LAN, use your servers lan ip. 192.168.?.?:8080
If you can't get to it from another machine on your LAN, you may have firewall issues on the server
2.Making sure your network is configured properly
This is where port forwarding comes into play. Figure out the LAN ip of the server and log into the router.
Tell your router to forward the port (8080 in this case) to the server LAN ip address.
Test it by telling your friend to access your server on (WAN_IP:8080 in web browser)

Resources