[Solved]-How to configure Apache to run ASGI in Django Channels? Is Apache even required?


As mentioned by Lukasa, I stopped the Apache server, which at first stopped my django app getting delivered out to the world.
Then I ran the following commands:

sudo daphne MyProject.asgi:channel_layer --port 80 --bind -v2
sudo python manage.py runworker -v2

The two commands started delivering the app to http requests from outside the server. No other configurations were required other than mentioned in the question post.


Currently Apache does not have an ASGI server implementation. That means that you can continue to use Apache, but you will also need Daphne. In essence, Apache will change from being your primary web server to being a reverse proxy.

There is potentially some value in doing that: Python developers have been running nginx in reverse proxy mode for years. However, Daphne is a very capable web server, being built on top of Twisted’s web server, and so Apache certainly isn’t necessary.

For that moment, then, I recommend running just with Daphne: have Daphne listen on your primary ports and disable Apache altogether. If you find there are features of Apache you still want, you’ll need to configure Apache as a reverse proxy: one suggested article for configuring that is this one from Digital Ocean.


Leave a comment