You cannot call this from an async context - use a thread or sync_to_async

I am using Async function in my django program, and tested it on development laptop PC, it has no any issue. but after uploaded to my own PC server, then face: " SynchronousOnlyOperation at /convertor/ You cannot call this from an async context - use a thread or sync_to_async", I have checked django, python, and other tools’s version, they are the same with my laptop PC side, this is really strange, why it works on laptop PC, then doesn’t work on the server When I access it with a locap IP: http://12.23.282.232:8000

the interesting thing, if I started the django app on the server side locally, then if I access it via lcoahost:80001, it works, there is no " SynchronousOnlyOperation at /convertor/",

the log:

SynchronousOnlyOperation at /convertor/

You cannot call this from an async context - use a thread or sync_to_async.

Request Method: POST
Request URL: http://12.23.282.232/convertor/
Django Version: 5.1.5
Exception Type: SynchronousOnlyOperation
Exception Value: You cannot call this from an async context - use a thread or sync_to_async.
Exception Location: /home/xeon/.local/lib/python3.10/site-packages/django/utils/asyncio.py, line 24, in inner
Raised during: app.views.submit_handler
Python Executable: /usr/bin/python3
Python Version: 3.10.12
Python Path: ```
[‘/home/kvm/insight’,
‘/usr/bin’,
‘/usr/lib/python310.zip’,
‘/usr/lib/python3.10’,
‘/usr/lib/python3.10/lib-dynload’,
‘/home/xeon/.local/lib/python3.10/site-packages’,
‘/usr/local/lib/python3.10/dist-packages’,
‘/usr/lib/python3/dist-packages’,
‘/home/xeon/.local/lib/python3.10/site-packages/setuptools/_vendor’]

Welcome @bhuo !

How are you running your project in both places?

Also, please post the view that is throwing this error, and the code for any functions you have written that are called by this view.

Also, if you are running this asynchronously, post your asgi.py file from both environments.

Finally, it may help if you posted the traceback from the server showing the complete exception being thrown.

Thank you for your response. I have resolved the issue, which was caused by not stopping the gunicorn.service on the server side