Internal Server Error: Dash on Flask on AWS Elastic Beanstalk


NB: Dash is a python package used to build dashboards by plotly (website here). Flask is a python package used to build python web frameworks (website here and AWS tutorial here). I am using python 3.6 and all package versions can be seen below in requirements.txt

Problem: I get an error when launching my Dash app onto my AWS EB.

When I run locally on my dash works. However when I $ eb deploy I get this on my AWS EB URL:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

My file structure is as so (where eb-flask is my flask directory):

When using $ eb config:

My code is pretty much lifted from as test.

requirements.txt is obviously pip freeze. At this point it is just the required packages for flask, dash and plotly:

Something is obviously wrong server-side. When I run (eb-virt) $ python I can access the site locally. I get this response from a HTTP GET:

Yet when I $ eb deploy I get the aforementioned Internal Server Error. I appreciate any help.

When I enable logging, I get application.logger.addHandler(handler) AttributeError: 'Dash' object has no attribute 'logger' locally. On deploying, there are no errors appended to the log file, it just remains blank.


I think the issue is that the application.run_server(debug=True) method has localhost as a default host. This means that the app is deployed to and you can access it only from the inside of the machine where it’s running. This explains why you could only access the app locally (whether it was from your computer or inside the instance). When deploying to Elastic Beanstalk you need to specify host as – all IP addresses (deploying with debug=True in production is discouraged!):

Check this GitHub sample Flask app Beanstalk deployment.

Leave a Reply