Spring Boot Application deployed on Elastic Beanstalk Java environment returns 502
<p>I'm trying to deploy a very simple Spring Boot application on AWS Elastic Beanstalk using AWS's Java configuration (not their Tomcat configuration), but I keep getting a 502 error with the following log: </p>

<pre><code>2016/06/10 02:00:14 [error] 4921#0: *1 connect() failed 
(111: Connection refused) while connecting to upstream, client: 38.94.153.178,   
server: , request: "GET /test HTTP/1.1", upstream:   "http://127.0.0.1:5000/test",
host: "my-single-instance-java-app.us-east-1.elasticbeanstalk.com"
</code></pre>

<p>I've tried setting my port via Spring's application.properties to what the log seems to want (5000, using <code>server.port=5000</code>) and have verified that my application runs successfully on that port on localhost.</p>

<p><a href="https://stackoverflow.com/questions/34619548/beanstalk-502-bad-gateway-spring-application">This question</a> is very similar, except that I'm deploying a JAR instead of a WAR. It seems like there is something I'm missing regarding configuring Nginx, and I don't know how to proceed.</p>

<p>Here's my Spring Application:</p>

<pre><code>@SpringBootApplication
public class MyApplication {

    public static void main(String[] args) {
        SpringApplication.run(MyApplication.class, args);
    }

    @RestController
    public static class MainController {

        @RequestMapping("/test")
        public String testMethod() {
            return "Method success!";
        }
    }
}
</code></pre>