Can't configure node_chat to localhost - node.js

I went to configure server.js but I get the error connecting to server.
HOST=localhost;
PORT= 80;
http://github.com/ry/node_chat

Try using a different port. I believe node.js has some trouble listening on port 80

Related

Don't see nodeJs serveur port working / same port client/server don't cause error

I have an application which work with React/socket/nodeJS on a VPS.
This VPS use apache as php engine and when I check the config, it listens the port 7080.
My nodeJS work on any port 80 / 3000 / 7080 etc... and when I use netstat on my console VPS I don't see this <IP:SERVERPORT>.
Here is the problem I face:
1. Why I can't see my server PORT running on my VPS with netstats? ( I see console log from my server so he work)
2. Why it work with the same apache port? Normally I have to use a server port different from the client...
For information, my vps is dedibox (online.net with plesk).

What else is required to access a node app from outside a Digital Ocean droplet?

We have set up a node server which runs on port 5000.
In a newly created droplet, we have installed and started nginx. To access the node app, we have changed the default port from 80 to 5000 in /etc/nginx/sites-enabled/default
server {
listen 5000 default_server;
listen [::]:5000 default_server;
ufw is enabled
sudo ufw enable
Also the port is enabled
sudo ufw allow 5000/tcp
Also, tried this way too:
sudo ufw allow 5000
As confirmed with sudo ufw status
netstat -ntlp
Also the app is configured to listen on the public interface
const server = app.listen(process.env.PORT || 5000, '0.0.0.0', () => {
console.log('Express server listening on port %d in %s mode', server.address().port, app.settings.env);
});
However, not even the default port was responding. Hence, we reverted to 80 as the default port.
What else is required to access node app outside of the droplet?
When it comes to NodeJS and NGINX, we'll want to configure NGINX to listen on port 80, though we'll want to use proxy_pass to pass the request from the web server (NGINX) to the NodeJS application on the port that the application is running on. This will allow us to keep the port out of the URL.
With the current configuration, NGINX would be listening on port 5000 which would prevent the application from being able to listen in on the same port (or vice versa).
There is an excellent guide that covers setting up NodeJS + NGINX -- this specific part is the most important:
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-16-04#set-up-nginx-as-a-reverse-proxy-server
The above covers how we'd go about setting up the Server Block :-)

how to allow access to port on AWS

I am trying to connect to my development port port 3000 on aws but it is not working. I have currently configured my domain with the instance and it is working fine but I cannot access port 3000 and get ERR_EMPTY_RESPONSE
The security group setting is as below
As you can see, I have opened up my mongo port 27017 and 3000 which is my node server port
As you can see here, it is listening at port 3000. I set it to print out the exact port that is being listened.
When I go netstat -natlp the following shows
port 3000 is currently listening.
I have followed all the instructions and suggestions but it is still not working for a weird reason. The server I use is Asia(Seoul) server.
Am I missing something here?

socket.io try to listen to default apache port

In my Node.js script, I set socket.io to listen on port 8080:
client = require('socket.io').listen(8080).sockets);
Then I can connect with io.connect('http://.../8080').
But why, in the firefox/chrome consoles, I see multiple GET requests on port 80?
Like these :
GET http://.../socket.io/?EIO=2&transport=polling&t=1408319587655-58
GET http://.../socket.io/?EIO=2&transport=polling&t=1408319592695-59
GET http://.../socket.io/?EIO=2&transport=polling&t=1408319597750-60
Those links are working with port 8080.
Shouldn't it be io.connect('http://...:8080') and not io.connect('http://.../8080') ?

EC2 hosted Node.js application - can't remotely connect to port

Update: Turns out the only problem was that I was behind a firewall that blocked some ports, but not 8000.
Edit: TL;DR: can't connect to port 9000 remotely, but port 8000 is ok and I don't know why :(
I've got this node.js application that's running on port 8000 and another one (http-proxy) running on port 9000.
Running them on my machine is fine, but I have some problems when I put them up on a server (EC2 instance - I did open the ports in the web console security group[1]). The application works fine, but I can't connect to the proxy from outside. I tried to $ telnet localhost 9000 on the server and it connects, so I guess that's a good sign.
Another thing that I have noticed is that if I try to run the applications separately, I get the same results, i.e.: 8000 - OK, 9000 - NOTOK :<.
However, if I change the port the proxy uses from 9000 to 8000, it works. And if I switch the ports, i.e. application:9000 and proxy:8000, I can connect to the proxy, but not to the application. I have also tried other numbers, but that wouldn't fix it either.
I guess there's something really stupid that has nothing to do with the application itself and that I'm missing, but I can't put my finger on it, so does anyone have any idea why this setup doesn't work?
server.js
var express = require('express.io');
var app = module.exports = express();
require('./proxy');
app.http().io();
app.listen(8000);
// ...
proxy.js
var httpProxy = require('http-proxy');
var url = require('url');
httpProxy.createServer(function(req, res, proxy) {
// ...
proxy.proxyRequest(req, res, {
host: destination.host,
port: 80
});
}).listen(9000);
$ netstat -pln | grep node output
tcp 0 0 0.0.0.0:9000 0.0.0.0:* LISTEN 1487/node
tcp 0 0 0.0.0.0:8000 0.0.0.0:* LISTEN 1487/node
Security group rules
It turned out that the problem was not at all related to the application or the EC2 instance setup.
The network I was in while testing this was blocking some ports. This is why when moving the proxy to port 8000 it was working fine, but on 9000 or any other random ones that I tried it wasn't. D'oh!

Resources