Cannot connect to EC2 instance using port other than 22 or ping - amazon-web-services

I have my EC2 instance security group inbound rule to accept my ip as follows:
Outbound rule as follows:
I can connect to my instance using ssh and also ping my instance from my local machine without any issues.
When I have a server running on my EC2 instance on http protocol in port 9999 I am unable to access this site.
netstat -peanut gives me the following output on the server:
I am not sure why I am not able to access the http page locally? Should anything change in my inbound rule? I tested this on Amazon linux and ubuntu images. Nothing works.

Even though I have opened all ports on my security group aws seems to be allowing me to only access the common ports like 22, 80 and so on.
The only way I could finally access my remote server on port 9999 was by ssh tunneling:
ssh -TNL 9999:127.0.0.1:9999 <user>#<ip-address>

Related

is it possible to access a ec2 instance where inbound rule is only allowed for ssh with the help of apache http

I need to access an ec2 instance using http but inbound rule is only allowed for ssh.So is it possible to access the ec2 through http if i connected the ec2 using ssh and installed apache http.
It can be resolved using changing the inbound rule but is it possible by apache http without changing the inbound rule
Yes. You can activate Port Forwarding across your SSH connection, which will allow traffic to go across the SSH connection to the web server on the destination EC2 instance, and it will all happen via port 22 (SSH).
For example, this command will forward local port 8000 to the remote port 80:
ssh -i key.pem ec2-user#IP-ADDRESS -L 8000:localhost:80
You can then access the remote web server from your own computer by pointing your web browser to http://localhost:8000. The traffic will be sent across the SSH connection to the EC2 instance, where it will be sent to localhost:80 (which is the web server on the EC2 instance).
For details, see: How to Use SSH Port Forwarding {Ultimate Guide}

Not able to change port from 80 to any other port in AWS

So i have created an EC2 instance in AWS and i have attached security group for this which has HTTP port 80 which comes by default .
I also has assigned public ip for this instance and which is working fine .
When i change port of my IIS serve to 8080 or 800 or anything page is not able to display .
Even i have changed to Custom TCP rule and given that port but still i am not able to access from outside of AWS .
I have tried accessing using DNS as well .
Can some one help me resolve this ..
To access any port of EC2 instance you must do below things:
On EC2 instance do not enable firewall, instead of this we have AWS service called Security Group which helps us to access respective instance ports as required.
Now, you must have a security group which has Http port 80 and ssh port 22 enabled (port 22 for secure shell), so now you can add port 8080 or any other ports in that list of inbound rules. I have attached screenshot below:
Now, try to access your ports from outside (you can put http://publicIP of ec2 instance:8080 in browser to check if port is accessable from outside), and check if its working fine. Also make sure to have openSSH on machine from where your'e going to access EC2 instance.

EC2 instance gives ssh connection time out error after installing SSL certificate

I am using an Amazon EC2 instance for the last 2 months but today I am unable to connect to it. Earlier I was connecting using ssh and the service is still running (http://ec2-13-233-199-251.ap-south-1.compute.amazonaws.com).
Last night I tried to add an SSL certifcate from Let's Encrypt using this blog: https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-16-04
After that, when I try to connect to the EC2 instance using ssh as:
ssh -i "majorPillar.pem" ubuntu#ec2-13-233-199-251.ap-south-1.compute.amazonaws.com
I am getting connection time out error.
I checked my security group and port 22 is open and other inbound and outbound rules are correct. How can I connect to my instance now?
the port 22 in your server does not respond, 443 port refuses connections.
Double check your configuration in aws console:
inbound traffic configuration on port 22, ensure your ip address has access to that port.
For example:
nc -zv 13.233.199.251 22
The https certificate install should not have side-effects on ssh config.
Anyway, check /etc/ssh/sshd_config configuration file too and ensure ssh port is the one you want (22?)
sudo grep Port /etc/ssh/sshd_config

Accessing ElasticSearch on EC2 instance from outside the cloud

I am trying to access my ElasticSearch on a running EC2 instance from outside the Cloud. I currently have SSH/HTTP/HTTPS open to the public for inbound traffic as well as all open for outbound traffic. I set up a public IP for my EC2 instance as well.
By default ElasticSearch is on port 9200. I'm not sure if I configured my elasticsearch.yml file correctly but it basically has the default configuration I only changed the cluster.name to something else.
When I type in my public IP with port 9200 into my local browser or locally do a telnet {public-ip} 9200, there is no response. When I SSH into my EC2 instance. I can perform a curl localhost:9200 and I get the correct response from elasticsearch
How can I connect to my ElasticSearch running on my EC2 instance from outside the cloud?
I added a Custom Rule for my security group for inbound traffic that includes port 9200 and is open to 0.0.0.0/0 and I still cannot access this EC2 instance
Potential issues to check are wrong binding and instance operating system firewall.
Check where elasticsearch is binding, as if it is binding to 127.0.0.1 you won't be able to reach it from the outside.
Check binding by running in one shell on the elasticsearch ec2:
sudo netstat -lptun | grep 9200
If it shows 127.0.0.1:9200 then there is a misconfiguration if otherwise shows
*:9200 or :9200 then it is correct.
If it shows 127.0.0.1 then you should modify elasticsearch parameter network.bind_host as described in:https://www.elastic.co/guide/en/elasticsearch/reference/1.4/modules-network.html
Additionally http/HTTPS and ssh are usually allowed by default operating system firewall, whereas elasticsearch 9200 is not. This is usually the case for rhel and centos. You can temporarily disable iptables and check if it works.
To disable iptables run:
sudo iptables -F
If after disabling iptables the connection works you should configure iptables to allow connection on 9200.
I hope this helps.
G.
It is mess around Security Groups
You can add or remove rules for a security group (also referred to as
authorizing or revoking inbound or outbound access).
You shuld use the SG while launching your instance whith bounded 9200
Establish an SSH tunnel from your desktop to EC2.. then simply use your browser.. follow steps as given in https://www.jeremydaly.com/access-aws-vpc-based-elasticsearch-cluster-locally/

Amazon EC2 HTTP connection refused, but HTTP port is open

I created a new Ubuntu T2 Micro instance on EC2.
Created a new Elastic IP and selected "EIP used in: VPC"
Associated the address to my new EC2 Ubuntu instance.
I now have a Private IP and a Public/Elastic IP. No Public DNS.
My security group has SSH port 22 and HTTP port 80 open.
I can connect to the instance just fine through SSH using the Public IP, but when I try to browse to the Public IP through the browser it says connection refused. I can't ping it either.
I'm out of ideas.
Amazon EC2 HTTP connection refused, but HTTP port is open
That's already proven by the fact that you got 'connection refused'. If the port wasn't open it would have been 'connect timeout'.
'Connection refused' means that the service you tried to connect to wasn't listening at that port. Possibly it isn't started at all, or even installed.
You need to install a web server on your machine, such as Apache or Nginx. This is not provided by default in EC2.
go to security groups --> edit inbound rules --> add rule (add a custom TCP port 8888 with 0.0.0.0/0 ).
There are two major things that can happen to your web server.
Connection refused :- Which means there is no service running (http/JBOSS/nginx) on your server which is available to accept connections on port specified (which is 80 in this case)
Connection timed out :- Would mean server is not able to process any incoming connection hitting it at port 80. Once you fix the security group and your NACL (if you don't have a default one), then you need to re-check to see if it's service which is giving out the error, not to forget that the error response will change.