Does node.js server need internet connection to run? - node.js

I disable the internet connection and run the node server npm start, then it throws the error:
And now enabling internet connection and running the server works fine:
So, I want to confirm if this really needs to be connected to the internet while starting the server?
If it really needs internet connection, then is there any idea to run the server offline?
If I connect to the internet and run the server and there after plug out the internet connection then there's nothing goes wrong. Everything works fine. I don't know why just running the server requires the internet connection.

OMG! It's really cool! I got it working offline after hard research in my code using 127.0.0.1 instead of localhost for mongo uri.
Using localhost needed for me to connect to the internet.
And using 127.0.0.1 worked in both condition i.e. with internet connection and without internet connection.
But, really I'm totally amazed of this.
I found the really cool topic on this which made me clear about this.
If you use 127.0.0.1, then (intelligent) software will just turn that directly into an IP address and use it.
And there's no guarantee that your hosts file will actually be used for that resolution (first, or at all) so localhost may become a totally different IP address.

Related

Can connect to nginx server inside LAN but not publicly

I'm trying to set up a Mastodon instance on my Raspberry Pi 4 at home, running Raspbian/Debian Linux. I have no idea what I'm doing.
The nginx server is running, working. When I access it from localhost or from inside the LAN, it gives a result like this, as expected:
When I try to access it from outside the LAN, it eventually times out or gives a "connection was reset" error.
Or in firefox:
At first I suspected that it was a problem with my firewall, like maybe it was blocking HTTP traffic into it. But it's allowing HTTP traffic through. I even stopped the firewall entirely, but it's still doing the same thing. (I'm using IPTables)
All of the necessary ports should be forwarded to the pi on my optimum router:
Here's the site's nginx config, just an edited copy of mastodon's given nginx configuration template. I have the HTTPS server commented out, as I'm only working with HTTP right now. I'm trying to get the http server working so I can use certbot to get an SSL certificate, but certbot's unable to connect to the nginx server, runs into the same "connection reset" error. The server_name is irrelevant (or is it?) as i'm just trying to connect to it through IP right now, and commented out the other "location" properties that the template came with, as I'm just trying to get the server to work in the first place, running mastodon on it and getting the SSL certificate and getting the domain to work will come after.
What causes it to work inside LAN but not outside it? Even with the necessary ports forwarded to the pi?
Edit:
Here's what it looks like inside the LAN, working correctly:
and here's when I try to access it outside the LAN (through ProtonVPN in this case)
https://www.reddit.com/r/OPTIMUM/comments/rxjw1v/optimum_internet_not_forwarding_traffic_on_port_80/
By default, Optimum blocks ports 80 and 25, even if they are port-forwarded.
Optimum support referred me to this obscure page that I couldn't find linked anywhere on the site, did exactly what i needed: https://www.optimum.net/internet/boost/

How to create socket connection over internet?

I have created a server-side and client-side console based Chatroom. I have done the port forwarding and also added the inbound rule to the firewall settings both in client-side and server-side. It is working fine with computers on the same network but when I connect to the server/socket with different network(mobile hotspot) it doesn't work. I know my public ip address and I have it tried using it also. I am using TCP connection and a port-'55555'. I have windows 10 os on my laptop. Also tried after disabling the virus protection, it didn't work.
Can you please suggest some ideas regarding how to make it work?

nginx Ubuntu nodeJs - Server only handles requests from local network

I followed all kinds of instructions all day to get my first server up and running. I tested it on 3 devices and thought I had it... until my friend tried it and discovered "site can't be reached."
In double-checking on my end, I found that if I disconnected my phone from wi-fi, sure enough, I couldn't reach my server.
I realize there could be a million things wrong, but I don't know where to start. I am not even sure what additional information I should include to help find the issue. If I had to guess, I'd say I failed to open the firewall on my server port 80. But I really have no clue. Ubuntu is new to me.
Can you include details about your setup? How is the Ubuntu server configured? If it's your own hardware, have you forwarded the ports on your router? Do you have a Dynamic DNS server in place? Is there an internal firewall (ufw?). Is the Node.js server bound to the loopback? Is Nginx in proxy_pass mode?
As mentioned by the OP, the ports weren't forwarded.

Amazon Nodejs webserver

I'm getting stuck here, so i have an amazon ec2 (standard redhat server) host up and working. i can connect to it personally no problem, however it cannot be connected to outside of my ip.
I've checked the rules and i have port 80 and 3000 open to 0.0.0.0/0 to be able to communicate, however outside of my computer (and computers in this network) i can not connect.
Everything I've found is about connecting to ssh which works fine, i have no rules in iptables, i haven't dealt much with them before, but since i can connect to the service i don't think its the issue.
summary:
Web server is running, i can connect from my computer to it, and any others in my local network, but nothing outside of it works.
i do have httpd installed as well as a simple forward from the browser to port 3000, however i cant connect to it either from outside my network.
so this is a new one for me, the dns forwarding works in houst, but not outside. so inside and outside here, i can use IP address to connect, but inside only i can connect with my dns lookup. not sure what caused this, but its not an amazon problem at least. going to look at that side.

How to tell on Linux (Lucid) if a connection is coming into the server?

So I have an issue where I am remotely connecting to a Mongodb on my linode box, and I am not longer able to access this DB. I can from my local machine, but when I am on this remote server (where the website runs) it is not working. I am not seeing the connection come into the Mongo logs, so this leads me to believe that maybe it is being intercepted by a firewall?
How can I watch traffic and see if this connection is at least making it to my linode box? I am connecting with Mongoid, so if there is a way to prove no connection there too.
Right now the only error I get is a erb view timeout execution error - not much to go on.
Thanks,
Daniel

Resources