-1

webpage is loading on localhost. but not with public IP. I get connection refused. so I checked port is listening but Its not. what can i do?

Add 8080 port Inbound rules

[ec2-user@springboot-webservice ~]$ netstat -ntl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:36145               0.0.0.0:*                   LISTEN
tcp        0      0 :::22                       :::*                        LISTEN
tcp        0      0 :::43675                    :::*                        LISTEN
tcp        0      0 :::111                      :::*                        LISTEN
coding cat
  • 23
  • 4

1 Answers1

0

Are you sure your application is running? If not, then go to your application directory a un run it. Gradle

./gradlew bootRun

Maven

./mvnw spring-boot:run

What port you specified for your application to run. If you don't specify any, by default it will run on port 8080. You can add server.port in your application.properties to change your port if you prefer.

  • src
    • main
      • resources
        • application.properties

#application.properties content

server.port=8080  #your port



#server.port=80  another port to test

If you have Spring Security in your dependencies, so that's the reason for the login page.

Check What is username and password when starting Spring Boot with Tomcat?

If you only can see you application on localhost, but can't expose your application to the world. Your EC2 instance is in a private subnet or a public subnet? Your application can only be seen if it is on a public subnet. Default subnets are always public subnet.

Maybe this tutorial can help you check if any steps are missing. https://www.javacodegeeks.com/2019/10/deploy-spring-boot-application-aws-ec2-instance.html