CINXE.COM
Deploying to Production — Flask Documentation (3.1.x)
<!DOCTYPE html> <html lang="en" data-content_root="../"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Deploying to Production — Flask Documentation (3.1.x)</title> <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=6625fa76" /> <link rel="stylesheet" type="text/css" href="../_static/flask.css?v=b87c8d14" /> <script src="../_static/documentation_options.js?v=d71c4578"></script> <script src="../_static/doctools.js?v=9bcbadda"></script> <script src="../_static/sphinx_highlight.js?v=dc90522c"></script> <link rel="canonical" href="https://flask.palletsprojects.com/en/stable/deploying/" /> <link rel="icon" href="../_static/shortcut-icon.png"/> <link rel="index" title="Index" href="../genindex/" /> <link rel="search" title="Search" href="../search/" /> <link rel="next" title="Gunicorn" href="gunicorn/" /> <link rel="prev" title="Security Considerations" href="../web-security/" /> <script async type="text/javascript" src="/_/static/javascript/readthedocs-addons.js"></script><meta name="readthedocs-project-slug" content="flask" /><meta name="readthedocs-version-slug" content="stable" /><meta name="readthedocs-resolver-filename" content="/deploying/" /><meta name="readthedocs-http-status" content="200" /></head><body> <div class="related" role="navigation" aria-label="Related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex/" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../py-modindex/" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="gunicorn/" title="Gunicorn" accesskey="N">next</a> |</li> <li class="right" > <a href="../web-security/" title="Security Considerations" accesskey="P">previous</a> |</li> <li class="nav-item nav-item-0"><a href="../">Flask Documentation (3.1.x)</a> »</li> <li class="nav-item nav-item-this"><a href="">Deploying to Production</a></li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <section id="deploying-to-production"> <h1>Deploying to Production<a class="headerlink" href="#deploying-to-production" title="Link to this heading">¶</a></h1> <p>After developing your application, you’ll want to make it available publicly to other users. When you’re developing locally, you’re probably using the built-in development server, debugger, and reloader. These should not be used in production. Instead, you should use a dedicated WSGI server or hosting platform, some of which will be described here.</p> <p>“Production” means “not development”, which applies whether you’re serving your application publicly to millions of users or privately / locally to a single user. <strong>Do not use the development server when deploying to production. It is intended for use only during local development. It is not designed to be particularly secure, stable, or efficient.</strong></p> <section id="self-hosted-options"> <h2>Self-Hosted Options<a class="headerlink" href="#self-hosted-options" title="Link to this heading">¶</a></h2> <p>Flask is a WSGI <em>application</em>. A WSGI <em>server</em> is used to run the application, converting incoming HTTP requests to the standard WSGI environ, and converting outgoing WSGI responses to HTTP responses.</p> <p>The primary goal of these docs is to familiarize you with the concepts involved in running a WSGI application using a production WSGI server and HTTP server. There are many WSGI servers and HTTP servers, with many configuration possibilities. The pages below discuss the most common servers, and show the basics of running each one. The next section discusses platforms that can manage this for you.</p> <div class="toctree-wrapper compound"> <ul> <li class="toctree-l1"><a class="reference internal" href="gunicorn/">Gunicorn</a></li> <li class="toctree-l1"><a class="reference internal" href="waitress/">Waitress</a></li> <li class="toctree-l1"><a class="reference internal" href="mod_wsgi/">mod_wsgi</a></li> <li class="toctree-l1"><a class="reference internal" href="uwsgi/">uWSGI</a></li> <li class="toctree-l1"><a class="reference internal" href="gevent/">gevent</a></li> <li class="toctree-l1"><a class="reference internal" href="eventlet/">eventlet</a></li> <li class="toctree-l1"><a class="reference internal" href="asgi/">ASGI</a></li> </ul> </div> <p>WSGI servers have HTTP servers built-in. However, a dedicated HTTP server may be safer, more efficient, or more capable. Putting an HTTP server in front of the WSGI server is called a “reverse proxy.”</p> <div class="toctree-wrapper compound"> <ul> <li class="toctree-l1"><a class="reference internal" href="proxy_fix/">Tell Flask it is Behind a Proxy</a></li> <li class="toctree-l1"><a class="reference internal" href="nginx/">nginx</a></li> <li class="toctree-l1"><a class="reference internal" href="apache-httpd/">Apache httpd</a></li> </ul> </div> <p>This list is not exhaustive, and you should evaluate these and other servers based on your application’s needs. Different servers will have different capabilities, configuration, and support.</p> </section> <section id="hosting-platforms"> <h2>Hosting Platforms<a class="headerlink" href="#hosting-platforms" title="Link to this heading">¶</a></h2> <p>There are many services available for hosting web applications without needing to maintain your own server, networking, domain, etc. Some services may have a free tier up to a certain time or bandwidth. Many of these services use one of the WSGI servers described above, or a similar interface. The links below are for some of the most common platforms, which have instructions for Flask, WSGI, or Python.</p> <ul class="simple"> <li><p><a class="reference external" href="https://help.pythonanywhere.com/pages/Flask/">PythonAnywhere</a></p></li> <li><p><a class="reference external" href="https://cloud.google.com/appengine/docs/standard/python3/building-app">Google App Engine</a></p></li> <li><p><a class="reference external" href="https://cloud.google.com/run/docs/quickstarts/build-and-deploy/deploy-python-service">Google Cloud Run</a></p></li> <li><p><a class="reference external" href="https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create-deploy-python-flask.html">AWS Elastic Beanstalk</a></p></li> <li><p><a class="reference external" href="https://docs.microsoft.com/en-us/azure/app-service/quickstart-python">Microsoft Azure</a></p></li> </ul> <p>This list is not exhaustive, and you should evaluate these and other services based on your application’s needs. Different services will have different capabilities, configuration, pricing, and support.</p> <p>You’ll probably need to <a class="reference internal" href="proxy_fix/"><span class="doc">Tell Flask it is Behind a Proxy</span></a> when using most hosting platforms.</p> </section> </section> <div class="clearer"></div> </div> </div> </div> <span id="sidebar-top"></span> <div class="sphinxsidebar" role="navigation" aria-label="Main"> <div class="sphinxsidebarwrapper"> <p class="logo"><a href="../"> <img class="logo" src="../_static/flask-vertical.png" alt="Logo of Flask"/> </a></p> <h3>Contents</h3> <ul> <li><a class="reference internal" href="#">Deploying to Production</a><ul> <li><a class="reference internal" href="#self-hosted-options">Self-Hosted Options</a><ul> </ul> </li> <li><a class="reference internal" href="#hosting-platforms">Hosting Platforms</a></li> </ul> </li> </ul> <h3>Navigation</h3> <ul> <li><a href="../">Overview</a> <ul> <li>Previous: <a href="../web-security/" title="previous chapter">Security Considerations</a> <li>Next: <a href="gunicorn/" title="next chapter">Gunicorn</a> </ul> </li> </ul> <search id="searchbox" style="display: none" role="search"> <h3 id="searchlabel">Quick search</h3> <div class="searchformwrapper"> <form class="search" action="../search/" method="get"> <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/> <input type="submit" value="Go" /> </form> </div> </search> <script>document.getElementById('searchbox').style.display = "block"</script><div id="ethical-ad-placement"></div> </div> </div> <div class="clearer"></div> </div> <div class="footer" role="contentinfo"> © Copyright 2010 Pallets. Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3. </div> </body> </html>