How to run a NODE.JS server on local wifi? - node.js

So I've tried making my server listen on IP - 0.0.0.0 and on port 8080, then when I open up the browser (Chrome) and type https://192.168.0.1:8080/, Chrome says 'This site can’t be reached'. Although when I run the server in the CMD it starts working totally fine, which I think should be a sign for the server actually running somewhere.
Everyone's help is very appreciated!

Related

Port not running but app wont stop running in browser - Windows - React - Node

So when I go to localhost:3001 it shows project I worked on before. I restart my computer, its still there, kill all node/vscode processes in task manager, its still there. I tried the npx kill port 3001 - seems ok says "port killed" but, the app still there in localhost 3001. When I use netstat findstr 3001 shows nothing there. When I use CurrPort or cmd to check all ports listening - 3001 doesn't show up.
If I listen in port 3000, everything works normal, but when I npm start another app in React itll take me to port 3001 and it doesnt give any error. Except when it opens on Port 3001 it doesnt display the app I npm started in, it still shows that ghost app that I cant get out of port 3001.
In the network tab of the ghost app/port 3001 it shows port 3001 there. I cant post screenshots cus low reputation but idk if something with the initiators in network tab might give a hint to what the problem is.
I could always just set it so React uses 3002 onwards or just run one app at a time in port:3000 buts its bothering that this ghost app has taken over a port.
Hopefully its just something stupid Im overlooking, but if anybody ever had a similar experience let me know!
TL:DR my port 3001 is showing not running listening everywhere I check but everytime I go to it it shows this old project and if I try to run another app at the port terminal says its running, everything ok ,but it is still that old app still there
So it seemed to be something with the browser not port, worked normal in another browser. So went into the inspector tools of the browser went in storage and deleted all cookies, cache, local&session storage and that fixed it. Also killing the service-worker.js process in the port worked for someone else who had the same problem from the project.

Access NodeJS server installed on Linux server

I created my App from this boilerplate
https://github.com/Bikranshu/express-react-boilerplate
Now I uploaded it to a live Linux server and Node server is running.
Screenshot of running server
But I am unable to access it through Browser with IP address of server.
http://ip_address:3000
After waiting long in browser it is showing timeout error.
Please guide me how can I access the node/react app from browser.
Server running at <ipaddress> is a local IP, are you in a different network than the server? If so, you should be typing https://<public ipaddress>:3000
UPDATE
Hosting services usually only forward port 80 (http) or 443 (https.) This means that your port 3000 is not allowed for public access. To fix your problem you need to change the listening port.
Check line 42 on
server/app.js change 'port' to "80" or check package.json and edit npm start to set port to 80

Vue application running on Digitalocean times out in browser

First time I try to use a node.js droplet on Digitalocean: I have a vue.js application running on port 8080, but it times out when I try to load the masterpiece in the browser (I don't have a domain so I use the [server IP]:8080 to access it).
I made sure 8080 is open in the firewall (ufw):
Netstat -pln gave the result seen in the screenshot below, a node program is running but nothing is named vue in case that would be required:
Tried export HOST=0.0.0.0 on advice from a friend, but didn't seem to do anything.
Tested curl 127.0.0.1:8080 from the digitalocean console and it works correctly.
The browser error message is err _ connection timed out.
Any tips on how to get this to show in the browser? As I'm not experienced in working with servers please give me step by step instructions. Thanks!

I can only access NodeJS server locally

My server's hosted at DigitalOcean (it's a droplet) and basically, I cannot access my NodeJS app via Internet, only server-side. It's running on port 9000, I've allowed traffic to the port via ufw and iptables, no luck. When I run curl || wget while SSH-ed to the server, I get a normal response as if everything's in order. But when I try to access the server from an another machine, I just get timed out because the server returns nothing. I've heard DigitalOcean sometimes disable connections to all ports except ssh,www and ssl, but I think I've successfully 'opened' them. Any suggestions?
This is what I get when I run netstat -tulp | grep LISTEN
Turns out my dashboard was all messed up when it comes to ports, which I forgot to check, of course, so opening them directly on the server gave no results whatsoever.

Node.js and Apache: connection issues

I have installed Node.js with Socket.io on a CentOS server which is running Apache on port 80.
I created a socket test, which justs listens on port 8080.
If I curl the address localhost:8080 from within the server's shell, I get the Socket.io-welcome message. If I have a line like this:
<script src="http://localhost:8080/socket.io/socket.io.js"></script>
Then the browser cannot find the file.
A "solution" was to proxy requests to /nodejs/ to http://localhost:8080/, but this solution did not work for very long.
Is it possible to run the Node.js server when we have Apache installed? Which settings must be changed in order for us to access the url: http://server.com:8080 ? It seems the Node.js only accepts connections from localhost.
Problem is most probably in your node.js program.
It should listen on 0.0.0.0 and not 127.0.0.1 which is local only.
So where you've got something like:
.listen(8080, '127.0.0.1'); // '127.0.0.1' or 'localhost'
You should change it to:
.listen(8080); // or 0.0.0.0
Apache will only interfere if it also uses port 8080 but you should get an error when starting your node app if this is the case.
Also, if you connect to http://localhost in your browser, it will only work if the server is on the same local machine as the browser. Fine for testing I guess.
You'll have to connect to a domain or ip address if you have a hosted server else no browser will find it.
Update:
Your socket.io code also needs to connect correctly:
var socket = io.connect('http://correct.server.com:8080'); // not localhost
and your browser needs to load the javascript file from the correct place:
<script src="http://correct.server.com/socket.io/socket.io.js"></script> // not localhost
This might help with firewall / load balancer issues:
https://github.com/LearnBoost/socket.io/wiki/Socket.IO-and-firewall-software

Resources