I can not access to the website with a public IP - amazon-web-services

I am setting up a new EC2 with Ubuntu, but I am getting a weird error and it is that I can not access to the public ip, it says refused connection.
My security group has these ports enabled:
HTTP TCP 80 0.0.0.0/0 -
HTTP TCP 80 ::/0 -
SSH TCP 22 0.0.0.0/0 -
SSH TCP 22 ::/0 -
My public is: http://3.16.154.123/
The EC2 interface is running, it's in green and that is the public ip which it gives me... so I wonder what is the problem? why can I not access to the public ip? why does it say refused connection? or more clear this error ERR_CONNECTION_REFUSED
Thanks.

telnet 3.16.154.123 22
Trying 3.16.154.123...
Connected to 3.16.154.123.
Escape character is '^]'.
SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
^]
Your ssh is working as expected but on port 80 it fails.
telnet 3.16.154.123 80
Trying 3.16.154.123...
telnet: Unable to connect to remote host: Connection refused
Can you check if there is any service running on the host itself using telnet localhost 80 - If this works then it will be worth to check the NACL at the vpc level for any block on port 80.

Related

AWS: Failed to connect to port XXXX: Connection refused

I am connected to an AWS server, where I want to host an Elasticsearch application. For that to work, I need to open a set of ports. In my AWS security group, I have opened the ones, which I consider as necessary. In order to check, whether that worked, I tried the following:
While connected to AWS via ssh, I typed curl localhost:3002, which outputs:
<html><body>You are being redirected.</body></html>
When I try the same over my local machine, i.e. curl http://ec2-xxxxx.eu-central-1.compute.amazonaws.com:3002, I receive:
curl: (7) Failed to connect to ec2-xxxxx.eu-central-1.compute.amazonaws.com port 3002: Connection refused
Does that mean, that the port 3002 is not open, or could there be another explanation?
Thank you for your help!
Edit:
The configuration in the security group looks as follows:
Ingoing:
80 TCP 0.0.0.0/0 launch-wizard-7
80 TCP ::/0 launch-wizard-7
22 TCP 0.0.0.0/0 launch-wizard-7
5000 TCP 0.0.0.0/0 launch-wizard-7
5000 TCP ::/0 launch-wizard-7
3002 TCP 0.0.0.0/0 launch-wizard-7
3002 TCP ::/0 launch-wizard-7
3000 TCP 0.0.0.0/0 launch-wizard-7
3000 TCP ::/0 launch-wizard-7
443 TCP 0.0.0.0/0 launch-wizard-7
443 TCP ::/0 launch-wizard-7
Outgoing:
All All 0.0.0.0/0 launch-wizard-7

Unable to restrict other IP's for SSH using AWS ec2 security group?

I would like to allow only specific Public IP to use pem file (SSH) .
I have added my ip only for SSH but I am able to connect with the same SSH in different public ip or lets say different computer with different internet.
Edit inbound rules
Type
Protocol
Port range
Source
Description - optional
HTTP TCP 80 0.0.0.0/0 -
HTTP TCP 80 ::/0 -
POP3 TCP 110 0.0.0.0/0 -
POP3 TCP 110 ::/0 -
All traffic All All 0.0.0.0/0 -
All traffic All All ::/0 -
POP3S TCP 995 0.0.0.0/0 -
POP3S TCP 995 ::/0 -
IMAPS TCP 993 0.0.0.0/0 -
IMAPS TCP 993 ::/0 -
SSH TCP 22 42.109.252.7/32 - //This is what I have added to allow myself only to use SSH
SMTP TCP 25 0.0.0.0/0 -
SMTP TCP 25 ::/0 -
IMAP TCP 143 0.0.0.0/0 -
IMAP TCP 143 ::/0 -
DNS (TCP) TCP 53 0.0.0.0/0 -
DNS (TCP) TCP 53 ::/0 -
HTTPS TCP 443 0.0.0.0/0 -
HTTPS TCP 443 ::/0 -
Actually I have a pem file available which I want that it should be accessible others only when I add their ip's from the AWS panel config of security group in inbound rules.
You also have a rule of all traffic from any IP in your security group list.
There is no specific ordering for security group rule evaluations so when this rule is the first evaluated you will find that a target IP is able to access any port on the EC2 host.
If you want to restrict IP addresses who can SSH to the host you will need to remove the following rules:
All traffic All All 0.0.0.0/0 -
All traffic All All ::/0 -

Cannot curl EC2 instance - Connection refused on port 80

So I have two instances, instance A is part of a security group sg-1 and instance B is part of another security group sg-2.
sg-1 has settings to allow all outbound traffic
sg-2 has settings to allow traffic from sg-1 on port 80, 9200 and 9300:
Yet, when I SSH onto instance A and try to curl instance B on port 9200, I get an error: Failed to connect to <Instance B Private IP> port 80: Connection refused
Not sure what I am doing wrong here?

Unable to access https endpoint of apache installed in EC2

I am running apache server within my ec2 instance and I am trying to access a static index.html. When I type http:// , I see the page displayed. However when I type https:// , the page isn't opening. Below is the security group setting. What am I missing?
HTTP TCP 80 0.0.0.0/0
HTTP TCP 22 0.0.0.0/0
Custom TCP Rule TCP 443 0.0.0.0/0

Can´t connect to my Amazon EC2 instance. It pings but connection times out

I did setup my 1st EC2 instance on AWS on a free tier using Ubuntu as the OS. I followed all the steps and my instance is up.
I´ve build the following security rules:
Ports Protocol Source Personal_SG_NVirginia
80 tcp 0.0.0.0/0 ✔
22 tcp 0.0.0.0/0 ✔
3306 tcp 0.0.0.0/0 ✔
443 tcp 0.0.0.0/0 ✔
-1 icmp 0.0.0.0/0 ✔
I can ping my instance, but cannot connect to it either using PuTTY, ssh on my linux and even on miniterm console.
$ ssh -vv -i "xxxx.pem" ubuntu#52.91.95.205
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: ssh_connect: needpriv 0
debug1: Connecting to 52.91.95.205 [52.91.95.205] port 22
debug1: connect to address 52.91.95.205 port 22: Connection timed out
ssh: connect to host 52.91.95.205 port 22: Connection timed out
Tha same happens if I use DNS name.
Miniterm console error:
Connection to 52.91.95.205: Connection timed out: no further information
I have already restarted the instance and recreated it, but no success at all.
Help appreciatted.
Verify the IP address is valid
$ ssh -vv -i "xxxx.pem" ubuntu#54.210.1133.50
Is this hand-written or did you copy and paste? The IP address is an invalid IP address ("1133" is >255), and doesn't match your debug output. Make sure you're connecting to the correct public IP address of the instance.
Verify you are using the correct user
Are you sure the initial user is "ubuntu"? Some EC2 Linux instances use "ec2-user" for the initial setup.
Try: ssh -vv -i "xxxx.pem" ec2-user#123.123.123.123
Verify default SSH port is not blocked (correct solution)
Per discussion below, it turns out that port 22 was blocked by the user's ISP. Switching to a non-standard port (2022) resolved the issue.