how to allow access to port on AWS - node.js

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?

Related

What does the localhost: 3000 server created by express mean?

What is it that you access when you type in "localhost: 3000" onto your browser? What does that represent?
localhost is a special domain name that always refers to your local computer.
3000 is a tcp port. When you open a url such as:
http://localhost:3000/
Then a connection will get opened to port 3000.
When you specify a url like:
http://localhost/
Then you will open port 80, because the default HTTP port is 80
localhost:3000 is a local development server running on port 3000 of your computer. It is created by the express and can render html pages and route the apis for different requests. With the expressjs framework you can create different routes and associate it with the development or production port. You can also change the port during the development which can be done by changing the value of listening port on your app/index/server .js file.

Trouble conecting to Node Server on EC2 Instance

I have a Node application running on an EC2 instance, and after npm start, I am unable to connect to the application via the web, but everything indicates that it is running correctly.
Here's how my server.js looks like:
app.listen(8000,"0.0.0.0", () => {
console.log("app running on port 8000");
});
How are the inbound rules of the EC2 security group:
I saw on other sites that removing " 0.0.0.0. " From app.listen and leaving only the port would solve the problem, but unfortunately that didn't work.
Another thing I tried was to add a * Custom TCP * rule to port 8000 in the security group, but this prevented the application from running, saying that the port was already in use
Something is already listening on port 8000, a netstat should tell you what it is.
Simply add a TCP security group for port 8001 or 8080 and in your code use that port instead.

I can't listen express server on port 80

I'm trying to create an express server using node.js but when I start the server on port 80 my friends can't use it. I can select any other port and it will work, but when I try port 80 it doesn't work. I'm using https://www.yougetsignal.com/tools/open-ports/ and https://portchecker.co/check to check if the port is openned, I tried with 3000 and it work perfectly, but I need to get it working in port 80. I have already disabled my firewall and setup my DMZ host in the router.
I believe you are using windows as OS. In it the port 80 could be used as default port for some service. Please check the following -
Skype uses port 80 by default, you can change this in skype options > advanced > connection - and uncheck "use port 80"
Port 80 is the standard HTTP port, so to check which services are using you could run net stop http. It will list the services using port 80 and will ask to whether end them or not.
Port 80 could be occupied by IIS server. Please stop IIS and then re-run the node service.
Some SQL Server Reporting services also use port 80

security issue nodejs port 4000

I am running nodejs (express framework) on port 3000 and works fine. Accidentally, I ran the program on port 4000 and I saw all of my data could be revealed like ftp. the interesting part is that just for port 4000 this happens and in my app I am just listening on port 3000
http://localhost:4000
result:
enter image description here

nodejs timed out on all ports when hosting on godaddy server

I've trying to run my nodejs/expressjs application on my godaddy server, but any port I use times out. I've tried using the application on my local device and it works fine. I have a snippet of my connection below.
var app = express();
app.listen(8080, function() {
console.log("Listening on port " + 8080);
});
When I run the program through ssh, I get no errors
node index.js
Listening on port 8080
But when I go to the corresponding location in my browser, I get:
xxx took too long to respond.
ERR_CONNECTION_TIMED_OUT
I'm pretty sure it has to do with running on the godaddy server. If anyone has experience using this service with nodejs, is there a specific port I should be using, or is there any other setup I should do?
Do you have a VPS with GoDaddy right? So I assume you have also root access.
SSH into your GoDaddy server as root and check if the node.js app actually listens on that port:
netstat -tunlp | grep 8080
If you see any result there for the node.js app and that port then the port is open.
By default, there should be a firewall on your server which might block most of the ports and allows only the necessary incoming traffic.
You can check if there is any rule for that port by issuing the command bellow:
iptables -nvL | grep 8080
If any result is returned, then you have to add an iptables rule to allow access to that port. There are multiple methods to do that:
permit full access from your IP access to the server
permit your ip to access port 8080 on the godaddy server
permit outside world to access port 8080 on your server
You could read any iptables guy, it's pretty easy to add/edit/delete firewall rules. Most of the cPanel/WHM servers come with CSF Firewall (which is based on iptables and perl scripts).
In order to allow an ip address to your firewall (if you have CSF Firewall installed) you have to issue the following command:
csf -a ip-address
I hope that helps!

Resources