- Newest
- Most votes
- Most comments
Hello.
Do you have an Elastic IP address configured for EC2?
If it is not set, the public IP address of EC2 will be changed when stopping and starting, so please try accessing with the changed IP address.
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html
Also, check if the application is running within EC2.
You can check the HTTP status code by connecting to EC2 and running the following command.
If this is other than 200, it is possible that the web server is not running.
curl localhost -I
If security groups and network ACLs are correctly configured and you haven't set up a firewall, the issue might be related to the application or web server itself.
Let's take a systematic approach to diagnose the issue:
First and foremost, confirm if your web server (e.g., Apache, Nginx) is running:
- For Apache: sudo systemctl status apache2 (or httpd on some distributions).
- For Nginx: sudo systemctl status nginx.
If it's not running, that's likely the reason for the error. Start the server and check again.
If your web server isn't automatically starting after the instance restarts, you'll need to enable it:
- For Apache: sudo systemctl enable apache2 (or httpd).
- For Nginx: sudo systemctl enable nginx.
This ensures that the web server starts automatically upon reboot.
Check the web server logs for any errors. They can give clues if there's an issue with the application or server configuration.
- For Apache: Check /var/log/apache2/error.log (this might vary based on the OS).
- For Nginx: Check /var/log/nginx/error.log.
Port Configuration: Confirm that your web server is set up to listen on port 80:
Regards, Andrii
Relaunch another image from the application and it shall run immediately.
Relevant content
- asked a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
Hello, Thanks for replying. So, I tried running 'curl localhost -I' on my EC2 instance, but it threw this error: 'Failed to connect to localhost port 80 after 0 ms: Couldn't connect to server'. So, I double-checked my Security Group Settings and Network ACL, and there's definitely no block on port 80. Furthermore, I have not configured any firewall, eliminating it as a potential cause for this issue.
The web server is probably not running, so try running the command to run the application again. https://aws-tc-largeobjects.s3-us-west-2.amazonaws.com/DEV-AWS-MO-GCNv2/exercise-3-compute.html
Does that mean that whenever I stop the instance, I will have to perform the steps mentioned in exercise-3 all over again to get the servers running?
I don't think it's necessary to recreate EC2. The application should be running by executing the following command, so I think it would be good if this command could be executed at startup.
After executing the command, I encountered a "KeyError: 'PHOTOS_BUCKET'". I had initially entered my S3 bucket name as instructed in the exercise, and it worked until I stopped the instance.
" File "/usr/lib64/python3.9/os.py", line 679, in getitem raise KeyError(key) from None KeyError: 'PHOTOS_BUCKET' "