Running a django project on windows server 2016 - IIS

Lukas Raszka 0 Reputation points
2023-10-24T16:35:08.4033333+00:00

Hello,

I’m trying to run a django site on windows server 2016. I am using IIS and FastCGI to do this. After trying to open the site in the browser, I get this error message:

Error occurred while reading WSGI handler: traceback (most recent call last).:File "C:\Python\Lib\site-packages\wfastcgi.py", line 791, in main env, handler = read_wsgi_handler(response. physical_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python\Lib\site-packages\wfastcgi.py", line 633, in read_wsgi_handler handler = get_wsgi_handler(os.getenv("WSGI_HANDLER")) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Python\Lib\site-packages\wfastcgi. py", line 605, in get_wsgi_handler handler = handler() ^^^^^^^^^ File "C:\Python\Lib\site-packages\django\core\wsgi.py", line 12, in get_wsgi_application django.setup(set_prefix=False) File "C:\Python\Lib\site-packages\django\__init__. py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Python\Lib\site-packages\django\apps\registry.py", line 83, in populate raise RuntimeError("populate() isn't reentrant") RuntimeError: populate() isn't reentrant StdOut:

I would be very grateful for advice and guidance on how to fix this error.

Have a nice day

Lukas

Windows for business | Windows Server | User experience | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Lex Li (Microsoft) 6,037 Reputation points Microsoft Employee
    2024-04-03T00:00:13.53+00:00

    The recommended way is to remove the deprecated wfastcgi and its settings from your web.config file, and then start from scratch with HttpPlatformHandler. You can learn more details from my blog post, https://docs.lextudio.com/blog/running-django-web-apps-on-iis-with-httpplatformhandler/

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration>
        <system.webServer>
            <handlers>
                <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" requireAccess="Script" />
            </handlers>
            <httpPlatform stdoutLogEnabled="true" stdoutLogFile=".\python.log" startupTimeLimit="20" processPath="C:\Users\<user name>\AppData\Local\Programs\Python\Python310\python.exe" arguments="manage.py runserver %HTTP_PLATFORM_PORT%">
            </httpPlatform>
        </system.webServer>
    </configuration>
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.