Skip to content

REST API returning http status 404 when deployed on EC2 instance on AWS

I have a simple spring boot app which has just 2 rest controllers and I am exporting the war for the same. I am deploying the same war using the tomcat manager on EC2 instance on AWS, but unfortunately I am getting http status 404 when trying to hit the API.

URL that I am trying to hit is –

[public IP shared by AWS]:[port number on which tomcat is running:8080]/[context route which is the name of my war file]/[my mapped urls]


My Controller class

public class TestController {

    public String returnCode() {
        return "returning code";

    public String returnReceivedCode(@RequestParam String code) {
        return code;


My pom.xml

        <relativePath/> <!-- lookup parent from repository -->
    <description>Demo project for Spring Boot</description>

I tried with java version 8 as well, the tomcat version that I have on my EC2 instance is 9 (apache-tomcat-9.0.70)

I also tried getting one sample war application that tomcat shares for the testing purpose –

But surprisingly, this is working fine which tells me that my tomcat and java installations don’t have any issues.

Any help would be appreciated.



As highlighted by @khmarbaise above, I was using spring boot 3.0.0 but I had java 8 installed on my EC2 instance and spring boot 3.0.0 requires java version 17+, and that is why I was getting 404 when hitting my APIs.

After downgrading my spring boot version to 2.7.6 I am able to get a corresponding response from the APIs.

Also, as mentioned by other comments regarding the use of “/”, omitting the slash was not an issue as the slash is an optional parameter.


User contributions licensed under: CC BY-SA
6 People found this is helpful