# ASGI Server in Development?

**URL:** <https://forum.djangoproject.com/t/asgi-server-in-development/37581>\
**Category:** Async/Channels\
**Created:** [December 31, 2024, 1:49am UTC](https://forum.djangoproject.com/t/asgi-server-in-development/37581 "2024-12-31T01:49:58Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![interglobalmedia](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/interglobalmedia/32/23637_2.png) [@interglobalmedia](https://forum.djangoproject.com/u/interglobalmedia)\
**Post date:** [December 31, 2024, 1:49am UTC](https://forum.djangoproject.com/t/asgi-server-in-development/37581/1 "2024-12-31T01:49:59Z")

</div>

Is it possible to use ASGI in development" Especially when the cloud platform I am deploying to uses ASGI, and certain code behaves differently in production from development. I have synchronous code which works beautifully in development and terribly in production. I don’t need asynchronous code throughout my application. Only for one case in my views and then in my javascript related to that view. Is it possible to set up an ASGI server in development so that I would know what to expect in production?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [December 31, 2024, 2:29am UTC](https://forum.djangoproject.com/t/asgi-server-in-development/37581/2 "2024-12-31T02:29:32Z")

</div>

See the docs for [How to use Django with Daphne](https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/daphne/) - there’s a section in there about its integration with `runserver`.

Side note: If you’re using Windows in either your development or your deployment environment, you are **likely** to face performance-related issues. Daphne/Twisted and Windows apparently don’t “play nice” together. (See this thread for a recent example: [Django Channels with Redis slow intialization](https://forum.djangoproject.com/t/django-channels-with-redis-slow-intialization/33470))

I have only ever deployed Daphne to Linux and have never faced any performance-related issues. Everyone I know who have tried to deploy it to Windows has faced some type of problem.

---

<div class="post-metadata">

**Author:** ![interglobalmedia](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/interglobalmedia/32/23637_2.png) [@interglobalmedia](https://forum.djangoproject.com/u/interglobalmedia)\
**Post date:** [December 31, 2024, 3:57am UTC](https://forum.djangoproject.com/t/asgi-server-in-development/37581/3 "2024-12-31T03:57:07Z")

</div>

Hi @KenWhitesell , thanks so much for your response. I am not on Windows. I am on Mac. I checked out the documentation and tried to install and use Daphne, but then I got back the error that my database was not properly configured.

---

<div class="post-metadata">

**Author:** ![interglobalmedia](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/interglobalmedia/32/23637_2.png) [@interglobalmedia](https://forum.djangoproject.com/u/interglobalmedia)\
**Post date:** [December 31, 2024, 4:17am UTC](https://forum.djangoproject.com/t/asgi-server-in-development/37581/4 "2024-12-31T04:17:12Z")

</div>

I tried installing and using Daphne again. This time, I double checked in the docs, and my error was that I didn’t place Daphne at the top of INSTALLED\_APPS. Now it works. The likes are working pretty well in development, but terribly on render. I wonder why that is. Am investigating. Thanks for your help @KenWhitesell!

---

<div class="post-metadata">

**Author:** ![interglobalmedia](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/interglobalmedia/32/23637_2.png) [@interglobalmedia](https://forum.djangoproject.com/u/interglobalmedia)\
**Post date:** [December 31, 2024, 4:42am UTC](https://forum.djangoproject.com/t/asgi-server-in-development/37581/5 "2024-12-31T04:42:08Z")

</div>

@KenWhitesell I checked again because Daphne was not being added to requirements.txt. 4.1.2 does not support python 3.13.0, and that is the version I am on. 4,.2 will support it whenever that comes out. What a pain. I was wondering why things were working so smoothly.

---

<div class="post-metadata">

**Author:** ![carltongibson](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/carltongibson/32/267_2.png) [@carltongibson](https://forum.djangoproject.com/u/carltongibson)\
**Post date:** [January 1, 2025, 10:23am UTC](https://forum.djangoproject.com/t/asgi-server-in-development/37581/6 "2025-01-01T10:23:47Z")

</div>

As far as I am aware there’s no incompatibility between the current Daphne version and Python 3.13. [The commit adding official support only updated metadata and testing configurations](https://github.com/django/daphne/commit/32ac73e1a0fb87af0e3280c89fe4cc3ff1231b37).

---

<div class="post-metadata">

**Author:** ![interglobalmedia](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/interglobalmedia/32/23637_2.png) [@interglobalmedia](https://forum.djangoproject.com/u/interglobalmedia)\
**Post date:** [January 1, 2025, 11:38am UTC](https://forum.djangoproject.com/t/asgi-server-in-development/37581/7 "2025-01-01T11:38:40Z")

</div>

Well, in the official GitHub repository, it explicitly stated that support for Python 3.13.0 would only be available in 4.2. And, when I checked my updated requirements.txt, it was not listed. And, subsequently, when I deployed to Render, the build failed.

---

<div class="post-metadata">

**Author:** ![carltongibson](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/carltongibson/32/267_2.png) [@carltongibson](https://forum.djangoproject.com/u/carltongibson)\
**Post date:** [January 1, 2025, 11:48am UTC](https://forum.djangoproject.com/t/asgi-server-in-development/37581/8 "2025-01-01T11:48:39Z")

</div>

> [@interglobalmedia](#):
>
> And, when I checked my updated requirements.txt, it was not listed.

You should be able to add `daphne==4.1.2` to that file, I think. (My point was only that _official compatibility_ is only a paperwork thing: there’s no actual incompatibility, so as long as Daphne is installed it should work.)

---

<div class="post-metadata">

**Author:** ![interglobalmedia](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/interglobalmedia/32/23637_2.png) [@interglobalmedia](https://forum.djangoproject.com/u/interglobalmedia)\
**Post date:** [January 1, 2025, 3:05pm UTC](https://forum.djangoproject.com/t/asgi-server-in-development/37581/9 "2025-01-01T15:05:55Z")

</div>

You mean to add it manually? I don’t know about that… There must be a reason that `pip install -r requirements` would not add it.

---

<div class="post-metadata">

**Author:** ![carltongibson](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/carltongibson/32/267_2.png) [@carltongibson](https://forum.djangoproject.com/u/carltongibson)\
**Post date:** [January 2, 2025, 8:40am UTC](https://forum.djangoproject.com/t/asgi-server-in-development/37581/10 "2025-01-02T08:40:02Z")

</div>

The `pip` command (only) installs the dependencies listed in the `requirements.txt` file. If Daphne is missing from there then it won’t be installed.

It’s necessary to add your dependencies to your requirements file so that they’ll be installed.

You can see what’s installed locally by running `pip list` or `pip freeze` and compare that to the contents of your `requirements.txt` file.

---

<div class="post-metadata">

**Author:** ![interglobalmedia](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/interglobalmedia/32/23637_2.png) [@interglobalmedia](https://forum.djangoproject.com/u/interglobalmedia)\
**Post date:** [January 2, 2025, 9:29am UTC](https://forum.djangoproject.com/t/asgi-server-in-development/37581/11 "2025-01-02T09:29:51Z")

</div>

I know all that. However, because it is incompatible with my version of Python, even thought I add it with pip in my virtual environment, it does not get added to my requirements.txt. I already did a pip list and pip freeze. It is listed there. However, when I run pip install -r requirements.txt it does not get added. And when that command is run on Render, it also doesn’t get added. Then the build fails. So I am just waiting until 4.2 comes out.

---

<div class="post-metadata">

**Author:** ![carltongibson](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/carltongibson/32/267_2.png) [@carltongibson](https://forum.djangoproject.com/u/carltongibson)\
**Post date:** [January 2, 2025, 10:08am UTC](https://forum.djangoproject.com/t/asgi-server-in-development/37581/12 "2025-01-02T10:08:40Z")

</div>

> [@interglobalmedia](#):
>
> …it does not get added to my requirements.txt

OK, so I’m not sure how you’re generating your `requirements.txt` file. It used to be `pip freeze > requirements.txt`

Again though, Daphne 4.1.2 is **not** incompatible with Python 3.13. The _official support_ literally only adds the metadata to declare that support, but there’s not upper version bound. You could try adding it to your requirements.

> [@interglobalmedia](#):
>
> So I am just waiting until 4.2 comes out.

Otherwise, yes, that’ll be the other option.

Good luck!

---

<div class="post-metadata">

**Author:** ![interglobalmedia](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/interglobalmedia/32/23637_2.png) [@interglobalmedia](https://forum.djangoproject.com/u/interglobalmedia)\
**Post date:** [January 2, 2025, 11:32am UTC](https://forum.djangoproject.com/t/asgi-server-in-development/37581/13 "2025-01-02T11:32:32Z")

</div>

Thanks! I am learning ALOT with this project. That’s the only way through trial and error.
