5

I'm using waitress to serve my Django app. I need it to serve the app on two ports simultaneously, in the same thread. (Can't be on a separate process because I need to be able to run it in my debugger in development.)

How can I do that?

1
  • 1
    Let your reverse proxy serve the content from a different port.
    – enthus1ast
    Jun 3, 2015 at 12:17

2 Answers 2

2

The latest version of waitress is now able to listen on multiple sockets, including IPv4 and IPv6.

Instead of passing in a host/port combination you now provide waitress with a space delineated list, and it will create as many sockets as required.

from waitress import serve
serve(wsgiapp, listen='0.0.0.0:8080 [::]:9090 *:6543')
1
  • If you use a configuration file, replace the "host" and "port" entries in [server:main] with "listen". May 3, 2020 at 5:04
0

I've never used waitress, but the latest documentation doesn't seem to mention using multiple ports. A quick clone and ack for 'port' and 'socket' through the code helped me find runner.py with documented command-line options, and the option --port=PORT doesn't seem to support multiple ports. That's not proof, but a good indication without digging too deep.

If I were to take a stab at adding this feature to waitress, then it sounds like select is what's needed.

Here's a StackOverflow example that uses select to bind a basic server to multiple ports.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.