This is a super short post that outlines one specific solution for anyone trying to deploy a simple Flask application using AWS Elastic Beanstalk and hitting a bad gateway error.
Solution
The Internet has some good stuff on helping you if you made a mistake elsewhere, but I did not find this basic check being mentioned anywhere. Make sure that your flask application variable is within if __name__ == "__main__":
.
I got lazy and initialized the application variable globally and was rewarded with a bad gateway error. Because I was new to the deploying apps using AWS Beanstalk, I ended up chasing all sorts of other hypothesis before checking if my app was being returned or not. What helped me, in the end, was to ssh into the EC2 instance behind the load balancer and check its logs.
So, if you are like me and struggling with a bad gateway error, perform this simple check before you go chasing after issues elsewhere.
I want to find out what conditions produce remarkable software. A few years ago, I chose to work as the first professional tester at a startup. I successfully won credibility for testers and established a world-class team. I have lead the testing for early versions of multiple products. Today, I run Qxf2 Services. Qxf2 provides software testing services for startups. If you are interested in what Qxf2 offers or simply want to talk about testing, you can contact me at: [email protected]. I like testing, math, chess and dogs.