I have my webapp running on Tomcat which is running on an EC2 instance.
I have set up my instance’s inbound rules properly.
When I enter <myWebsite.com>:8080
it works from my browser.
For <myWebsite.com>
it does not load. Rather I get the following error message:
This site can’t be reached <myWebsite.com> refused to connect.
Search Google for <my Website> home
ERR_CONNECTION_REFUSED
2
Answers
Ok, After following several answers in StackOverflow, following worked
Following didn't work
Note: My Ec2 instance's security group's inbound rules were accepting
HTTP
at port80
from anywhere.When you try to connect directly via
myWebsite.com
, your browser will default to http on port 80. Apparently, your webserver is listening on port 8080 though.You need to configure Tomcat to listen for incoming requests on port 80.
There are many tutorials and questions here on stackoverflow about how to change the tomcat port from 8080 to 80.
E.g from How to change the port of Tomcat from 8080 to 80?:
Keep in mind that, by default, Tomcat will not start on port 80, unless run as root. However, running as root is generally considered bad practice.
The following resource summarizes well how to mitigate this problem with Tomcat and EC2:
https://www.excelsior-usa.com/articles/tomcat-amazon-ec2-advanced.html#port80
The easiest solution would be to redirect the tomcat port (e.g.8080) via iptables: