Tomcat is running on port 80 but Connection Refused when trying to connect

Viewed 1044

I am trying to get Tomcat to work on port 80 & 443 with an SSL certificate. When tomcat first starts I can connect on port 8080 and everything looks great.

After that I modified the two lines in server.xml file to look like below

<Connector SSLEnabled="true" protocol="org.apache.coyote.http11.Http11NioProtocol"
        clientAuth="false" port="443" scheme="https" secure="true"
        sslEnabledProtocols="TLSv1.2,TLSv1.1,TLSv1"
        keystoreFile="/opt/tomcat/certificates/CERTIFICATE.pfx"
        keystorePass="PASSWORD"
        keystoreType="PKCS12" />

<Connector port="80" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="443"/>

After this I installed authbind and did the whole process with authbind and added authbind --deep to the tomcat start script.

Restart tomcat and it starts with no erros

querying netstat shows that 80 and 443 are listening

tcp6       0      0 :::443                  :::*                    LISTEN      17181/java
tcp6       0      0 127.0.0.1:8005          :::*                    LISTEN      17181/java
tcp6       0      0 :::8009                 :::*                    LISTEN      17181/java
tcp6       0      0 :::80                   :::*                    LISTEN      17181/java

when I try to curl localhost I get a connection refused error.

curl localhost
curl: (7) Failed to connect to localhost port 80: Connection refused

If I revert back to 8080 everything works fine. I have been scratching my head over this for hours. Please help me

2 Answers

Try:

etc/default/tomcat{VERSION} file -> set AUTHBIND=yes

then:

sudo touch /etc/authbind/byport/80
sudo chmod 500 /etc/authbind/byport/80
sudo chown tomcat{VERSION} /etc/authbind/byport/80

restart tomcat

Perform a check that your installation is correct and your configuration is correct.

Check your firewall, if it shouldn't be a problem, disable it.

Restart your server and check if it's available.

If it is still not available, post the log.

Related