AWS EC2 Instance (amazon Linux) refused connecting Custom TCP ports - amazon-web-services

I have created an EC2 (Amazon Linux) on Aws. I have a flask server which is running on port 8080. And have opened the same port in security group.
But the EC2 refused to connect on the 8080 port (xxx.xx.xxx.xx:8080), while the port 80 is accessible, I have Nginx running on port 80.

I tested the setup using the flask example and works for me : https://pythonprogramminglanguage.com/flask-hello-world/
Steps:
1 Launch a new Amazon EC-2 Instance (used Amazon Linux AMI)
2 Installed Python and pip.
[3] Created a new web.py file, (modified the port from 5000 to 8080 and added rule in the security group for EC2)
[4] Ran, python3 web.py

Related

How Is Port Forwarding Working on AWS without Security Group Rules?

Running an AWS EC2 instance with Ubuntu 22.04. I am also running a jupyter server for python development there and connecting to that from my local Ubuntu laptop with ssh tunneling.
#!/usr/bin/env bash
# encoding:utf-8
SERVER=98.209.63.973 # My EC2 instance
# Tunnel the jupyter service
nohup ssh -N -L localhost:8081:localhost:8888 $SERVER & # 8081:Local port 8888:remote port
However, I never opened port 8888 of the ec2 instance by a security group rule. How come the port forwarding is working in that case? Should not it be blocked?
When using ssh -L, ssh will listen to local port 8081 and will send that traffic across the SSH connection (port 22) to the destination computer. The ssh daemon that receives the traffic will then forward the traffic to localhost:8888.
There is no need to permit port 8888 in the EC2 instance security group because it is receiving this traffic via port 22.
An SSH connection does more than just sending the keystrokes you type. It is a full protocol that can pass traffic across multiple logical channels.

Can't connect to remote host from AWS EC2 instance

I have a database on a remote Google Cloud (GCP) machine. On GCP, I edited the firewall rules to allow access from my desktop and from an AWS EC2 instance. However, the following happens:
From desktop:
netcat -zv 35.198.56.213 27017
Connection to 35.198.56.213 27017 port [tcp/*] succeeded!
From EC2:
netcat -zv 35.198.56.213 27017
netcat: connect to 35.198.56.213 port 27017 (tcp) failed: Connection timed out
I don't understand why I can connect from my desktop but not from the EC2. Both IPs are allowed (using the instance public address). The outbound rules for the EC2 instance are allowing all traffic.
Any tips?
Edit: I am trying to connect to a mongo instance that is running on port 27017. The bindIp on /etc/mongod.conf is correctly set to 0.0.0.0.

AWS Cloud9 IDE "localhost refused to connect." while accessing docker container

In the Step 3 mentioned on https://github.com/stacksimplify/docker-fundamentals/tree/master/03-Pull-from-DockerHub-and-Run-Docker-Images ,
to run http://localhost/hello is throwing error ,
as http is not supported by cloud9 localhost (Reference : https://docs.aws.amazon.com/cloud9/latest/user-guide/troubleshooting.html#troubleshooting-app-preview-http ).
After updating local host port in the command to 443 ; https://localhost/hello getting error : "localhost refused to connect." Already added inbound rule for port 443 at VPC, Subnet and EC2 instance level.
docker run --name app1 -p 443:8080 -d stacksimplify/dockerintro-springboot-helloworld-rest-api:1.0.0-RELEASE
It appears that image is not compatible to run over HTTPS:
OpenSSL: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
Unable to establish SSL connection
Still, please share if you've any pointers to connect localhost on AWS Cloud9 IDE?

AWS ec2 exposed port is not working for Kubernetes forwarded port

I am new to devops. I have created an ec2 machine and opened the port 8080, while I am running a simple server I am able to access it publically.
http://localhost:8080 (from within the ec2 container) => hello world
http://ec2-15-206-178-112.ap-south-1.compute.amazonaws.com:8080 => hello world
Now I have installed a Kubernetes server which is accessible using kubectl from this instance, I am running a simple server on one of the pods and forwarded the port to ec2 8080 port.
kubectl port-forward pod/frontend-7496d5f6b8-clfx4 8080:80
Now from my Ec2 instance I can access it
http://localhost:8080 (from within the ec2 container) => hello world from pod
But I can not access it publically ( port 8080 is open in my security group )
http://ec2-15-206-178-112.ap-south-1.compute.amazonaws.com:8080 => Connection refused
Can someone point out what am I missing?
Kubernetes port forwarding by default binds only to 127.0.0.1. That is why you cannot access it using the public interface.
Use the following command to bind to all interfaces:
kubectl port-forward --address 0.0.0.0
You can check the related GH Issue here.

cannot reach my laravel site on 8000 port on aws ec2 ubuntu 18.04 instance

I am a beginner for AWS. I have launched AWS, EC2, ubuntu 18.04 instance. Now i need to launch my laravel application with a sub domain with port 8000 as laravel default port is 8000. i have created a sub domain with inbound rule for port 8000. But i cannot browse the sub domain When i try to browse with port 8000. but without port 8000, it works.
http://subdomain.mydomain.com - this works,
http://subdomain.mydomain.com:8000 - cannot reach