EC2 took too long to respond

0

I have a web server that I am running. I am attempting to load the test page by visiting the public DNS of the EC2 Instance. I keep getting the error that the instance "took too long to respond."

My security groups allow listening on ports 22 and 80.

When I add the port 443 the error changes to "refused to connect".

I ensured by running the service httpd status that the web service was active:

[ec2-user@ip-redacted ~]$ service httpd status
Redirecting to /bin/systemctl status httpd.service
● httpd.service - The Apache HTTP Server
     Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; preset: disabled)
    Drop-In: /usr/lib/systemd/system/httpd.service.d
             └─php-fpm.conf
     Active: active (running) since Sun 2023-06-18 05:05:28 UTC; 41min ago
       Docs: man:httpd.service(8)
   Main PID: 30282 (httpd)
     Status: "Total requests: 16; Idle/Busy workers 100/0;Requests/sec: 0.00645; Bytes served/sec:   3 B/sec"
      Tasks: 177 (limit: 1114)
     Memory: 18.3M
        CPU: 1.202s
     CGroup: /system.slice/httpd.service
             ├─30282 /usr/sbin/httpd -DFOREGROUND
             ├─30343 /usr/sbin/httpd -DFOREGROUND
             ├─30347 /usr/sbin/httpd -DFOREGROUND
             ├─30348 /usr/sbin/httpd -DFOREGROUND
             └─30350 /usr/sbin/httpd -DFOREGROUND

Jun 18 05:05:28 ip-redacted.ec2.internal systemd[1]: Starting httpd.service - The Apache HTTP Server...
Jun 18 05:05:28 ip-redacted.ec2.internal systemd[1]: Started httpd.service - The Apache HTTP Server.
Jun 18 05:05:28 ip-redacted.ec2.internal httpd[30282]: Server configured, listening on: port 80

I ran curl -v http://localhost and received:

[ec2-user@ip-redacted ~]$ curl -v http://localhost
*   Trying 127.0.0.1:80...
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET / HTTP/1.1
> Host: localhost
> User-Agent: curl/8.0.1
> Accept: */*
> 
< HTTP/1.1 403 Forbidden
< Date: Sun, 18 Jun 2023 05:38:49 GMT
< Server: Apache/2.4.56 (Amazon Linux)
< Last-Modified: Mon, 11 Jun 2007 18:53:14 GMT
< ETag: "2d-432a5e4a73a80"
< Accept-Ranges: bytes
< Content-Length: 45
< Content-Type: text/html; charset=UTF-8
< 
<html><body><h1>It works!</h1></body></html>
* Connection #0 to host localhost left intact

I'd like to have the test page pop up when I visit the public DNS.

1 Answer
1

Do you have your web servers configured to use HTTPS on your EC2?
If not, the connection will be denied even if port 443 is allowed in the security group.

Am I correct in understanding that port 80 and port 443 are allowed simultaneously in the security group?
How are you accessing from your browser when you have added port 443 permissions to your security group?
If only port 443 is allowed and you are accessing with "http", the connection will be denied in this case as well.

Also, the EC2 public DNS (amazonaws.com) is not your domain and I don't think you can access it via https using this.
If you want to access via HTTPS, please purchase a custom domain on Route 53 or similar and set up an SSL certificate.

profile picture
EXPERT
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions