Skip to content
Myr

waitress.rst

This file

Path

docs/deploying/waitress.rst

75 lines · 2.3 KiB

Last changed by

Merge branch '2.1.x'David Lordbefore adoption9139af1

History of this file

Take it

1Waitress2========34`Waitress`_ is a pure Python WSGI server.56*   It is easy to configure.7*   It supports Windows directly.8*   It is easy to install as it does not require additional dependencies9    or compilation.10*   It does not support streaming requests, full request data is always11    buffered.12*   It uses a single process with multiple thread workers.1314This page outlines the basics of running Waitress. Be sure to read its15documentation and ``waitress-serve --help`` to understand what features16are available.1718.. _Waitress: https://docs.pylonsproject.org/projects/waitress/192021Installing22----------2324Create a virtualenv, install your application, then install25``waitress``.2627.. code-block:: text2829    $ cd hello-app30    $ python -m venv venv31    $ . venv/bin/activate32    $ pip install .  # install your application33    $ pip install waitress343536Running37-------3839The only required argument to ``waitress-serve`` tells it how to load40your Flask application. The syntax is ``{module}:{app}``. ``module`` is41the dotted import name to the module with your application. ``app`` is42the variable with the application. If you're using the app factory43pattern, use ``--call {module}:{factory}`` instead.4445.. code-block:: text4647    # equivalent to 'from hello import app'48    $ waitress-serve hello:app --host 127.0.0.14950    # equivalent to 'from hello import create_app; create_app()'51    $ waitress-serve --call hello:create_app --host 127.0.0.15253    Serving on http://127.0.0.1:80805455The ``--host`` option binds the server to local ``127.0.0.1`` only.5657Logs for each request aren't shown, only errors are shown. Logging can58be configured through the Python interface instead of the command line.596061Binding Externally62------------------6364Waitress should not be run as root because it would cause your65application code to run as root, which is not secure. However, this66means it will not be possible to bind to port 80 or 443. Instead, a67reverse proxy such as :doc:`nginx` or :doc:`apache-httpd` should be used68in front of Waitress.6970You can bind to all external IPs on a non-privileged port by not71specifying the ``--host`` option. Don't do this when using a revers72proxy setup, otherwise it will be possible to bypass the proxy.7374``0.0.0.0`` is not a valid address to navigate to, you'd use a specific75IP address in your browser.