Unable to make API requests in AWS EC2 Windows instance - amazon-web-services

I have made a spring boot REST API (as a jar file) which links to MongoDB compass installed on the same EC2 instance.
When I run the jar file (in cmd) on my Windows 10 laptop (not the EC2 instance), it works totally fine and I'm able to make the http requests with Postman (from my IP). And when I run the jar file on my EC2 instance with cmd, it still runs normal and everything seems fine.
But this time I'm unable to make the http requests from anywhere. Postman says Could not send request Error: Request timed out.
I've tried using both the public IP and Public DNS IP. Going through the other solutions to questions similar as mine, I got to know that I'd to add inbound rules for all the ports which I'm using (8080 and 27017 in my case). I also enabled stuff from Windows Firewall in the EC2 instance but nothing helps me at the end.
Any help would be really appreciated.

Related

Unable to open Public IPv4 DNS in AWS EC2 - Linux instance

I have a Spring boot project which I want to host on an AWS-EC2 instance. I was able to create its image using Git-hub, Jenkin and docker. I was also able to successfully pull and run this image in the Linux console of my AWS-EC2 instance.
According the tutorial I was following I should have been able to open the project now using the public IPv4 DNS but the response I got was that it refuse to connect.
I know that this usually has to do with Inbound rules so I added a rule to allow all traffic but it didn't help.
For anyone who wants to know:
Git-hub repository: https://github.com/SalahuddinShayan/telecom
Docker-Hub repository: https://hub.docker.com/repository/docker/salahuddinshayan/telecom
Command I used to run the image in AWS:
docker run -p8081:8081 --name final-app --link docker-mysql:mysql salahuddinshayan/telecom
Security Groups:
Networking Details:
Here is the Error:
I am completely stumped by it. Does anyone an idea on what to do to fix this?
Please check if your client is calling the right protocol, e.g. http vs https.
You are transmitting on port 8081. http://3.110.29.193:8081/ works fine from the EC2 side. 404 status is raised, so this is a client side error, not a server side error.
It means that no firewall is blocking traffic and a process (your app) was found that listens on IP:Port that you require. The problem is that the process it encountered (your app) is sending only a WhiteLabel Error Page, which is a generic Spring Boot error page that is displayed when no custom error page is present. So the issue is with the Spring app itself and not with EC2 or with connection. In other words: the traffic can reach your Spring app, but your Spring app has nothing to say in response.
As a side note, after deploying your app I would advise to refine the inbound traffic rules to allow only the traffic you want. There is no need of allowing all traffic on all ports.

HTTP server on EC2 instance unreachable after a few minutes

I have a running instance on the Linux 2 AMI.
I have a default VPC and network interface.
Security groups taken care of, even opened all traffic and still got nothing.
There is an Internet Gateway
Routes are open on the VPC
The server is running
nginx is running
Once the instance is initiated and installed, all of this is ready
I can reach the http website the first 2-3 minutes, then it is unreacheable.
No idea why, everything else still running, can still ssh into the server, but http port 80 not running.
I opened everything from iptables, still nothing.
If I reboot the server, I get a minute where I can reach the server via http, but then a minute later its the same again.
I can reach http if I use $ wget http://localhost
So I think it is probably something from the EC2 control panel, not the instance itself.
I tried on new instances too.
Anyone has an idea?
The reason behind this weird behavior was that AWS abuse team had blocked some of my ports, had to upgrade to the developer plan to be able to know this, contacting them at the moment

Can't connect to EC2 Instance via Browser. Via terminal works fine

I launched an EC2 instance on Amazon Web Services and want to deploy Confluence on a Ubuntu 18.04 Server. Almost everything is set up now.
I just need the last step:
I need to call http://{ec2-public-ip}:8090 from my browser to do the last steps of configuration of Confluence via the frontend, as described in the instructions of Confluence (https://confluence.atlassian.com/doc/installing-confluence-on-linux-143556824.html).
I don't have any issues with connecting to the EC2 instance via ssh in terminal (macOS) as ubuntu and also as root by using privateKey.pem. This works fine. Installation of Confluence and setting up a MySql DB were also successful. EC2 instance is running. Getting a connection via AWS Session Manager also works, but opens a terminal in my browser and if I ping the EC2 instance via the AWS Session Manager, there is a 100% packet loss. Via local terminal on my mac there is 0% packet loss.
Also calling http://{ec2-public-ip}:8090 via browser causes ERR_CONNECTION_REFUSED in Safari, Chrome, IE and Firefox.
What I already tried:
Security Groups (All Traffic, MyIP); also tried to allow Any Traffic
Firewall completely off; Proxy completely off
Opened all necessary Ports in my Network (8090, 8000, 22, 23)
Emptied Browser Cache
Flushed DNS; new IP; rebooted router; rebooted EC2 instance
Does anybody have an idea how to solve this problem? I know that there have been a few discussion about this topic, but none of those comments or solutions worked.
I chose a different Port as selected by Confluence. This worked immediately.
The packet loss was caused by the already assigned HTTP Port 80, although Confluence uses 8090 by default. When I pinged the server, all of my packets have been delivered, while all incoming packets went to a different device in my Network. As result my Terminal told me, that no packet was delivered to my Mac. Which was obviously true.
Now everything is up and running just fine.
I saw that a lot of people in the Internet had the same problem. Just try it again but choose different Ports while installing Confluence on your Server.

Connection getting refused to socket.io server on Amazon EC2

I have set up a a micro EC2 instance on AWS. Currently, I am using the free tier in Oregon. There are two problems which I am facing.
When I try to SSH the instance using the public DNS, it says host does not exist but when I try conencting it using the public IP, it connects to it. What setting is needed to use the public DNS ?
I have opened the SSH client using the IP address. I want to set up my application which needs Node.js and MongoDB. I installed Node.js using this
Next I installed MongoDB using this
Then I connected to my instance using Filezilla and uploaded my code to it. I then start my node application which uses socket.io.
When I try to connect to socket.io server using web browser, I get a message which says connection refused "error 111". I have opened TCP port 80 in instance's security groups. In iptables, I have forwarded port 80 to 8080, but still it does not work. I have also checked that the firewall is disabled in ec2. Kindly help me to resolve this issue.
Did you check if all of the necessary ports are open on Amazon Security Policy?
What you can do is to allow all traffic on Amazon Security Policy for test and see if the connection goes well or not.
You might also check if you need access DB from outside. In that case, you also have to open the mongodb port and setup mongodb correctly as well.
Other tools that might useful to test firewall and connection issue will be tcpdump and syslog file
For the dns issue, did you try to nslookup on that name and see if the IP shown matches your server IP?
As Amazon gives a long DNS hostname for the server, I always use my own domain name. It's much easier.
example : ec2.domainname.com, which points to the Amazon IP address
Hope that help.
My problem is resolved now..
For the DNS issue, earlier I needed proxy to access internet, so I guess the DNS name was not getting resolved. When I tried using proxy free internet, I was able to ssh using public DNS.
And regarding connection to socket.io, I used port 8080 instead of 80 and used "sudo node main.js" to run my node file. Now I am able to connect to the socket.io server and MongoDB.
Another thing which I want to ask is that would running the node file with sudo rights create some security issue ?
Thanks for the answer! That also worked for me. I had the same problem trying to connect through sockets (http://myipaddress:3000) to a node.js server, i tried opening ports on the actual ec2 instance and disabling the firewall through SSH but nothing worked. Had to go to Security Groups on the ec2 console and open a new inbound tcp rule enabling that port

Open app from AWS instance

First of all let me say that I'm new to AWS and don't know much about servers but trying to learn something now!
I have been given access to AWS instance. I can access the server using ssh. It's ubuntu server.
There is an application deployed under var/www/. I have also public IP of server but when I try to access this public IP it's not opening and I also can't ping that IP.
Am I doing something wrong? I will note that I don't have very big experience with servers.
You will need to check security group credentials associated with your ec2. There http and any other required protocols will need to be opened. And also that internet gateway is correctly NATed. Good luck. It's a steep but fast learning curve with aws.