I have read all posts about this issue, here and on IIS forum, got it to the second page on Google too... and still can't get it to work.
I want to run Flask/Python app in IIS on Windows server 2016, but I keep getting this error:
HTTP Error 500.0 - Internal Server Error
C:\Program Files\Python38\python.exe - The FastCGI process exited unexpectedly
Detailed Error Information:
Module FastCgiModule
Notification ExecuteRequestHandler
Handler FastCGI-Python
Error Code 0x00000002
I managed to get it work on my machine (Windows 10), but on server nope.
Environment
- Windows Server 2016
- IIS 10
- Python 3.8
- wfastcgi 3.0.0
- Flask 1.1.1
I tried different versions of Python (3.6, 3.7, 3.8). On my Windows 10 it's running Python 3.7 and it's working fine. I can't use Python 3.4.2, as it was suggested in one of the posts, because Flask runs on 3.5 and higher and apparently wfastcgi
works fine with Python 3.7 on my machine.
I granted full permissions to my application pool and to IIS_IUSRS on my web app folder and Python folder.
I have installed Microsoft C++ Build Tools too.
And the configuration of IIS has been shared from my machine to server through "Shared Configuration", so everything is the same. I just adapted some paths in config file.
I tried also running web app on Flask WSGI server for development and it worked fine.
Does anyone has a clue what more I can do? Any advice would be nice.
Thanks :)
EDIT: I've added a warning message from event viewer.
+ System
- EventData
Path C:\inetpub\history\CFGHISTORY_0000000051
12000780
--------------------------------------------------------------------------------
Binary data:
In Words
0000: 80070012
In Bytes
0000: 12 00 07 80
EDIT: Added web.config file
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<remove name="FastCGI-Python" />
<add name="FastCGI-Python" path="*" verb="*" modules="FastCgiModule" scriptProcessor="C:\Program Files\Python38\python.exe|C:\Program Files\Python38\lib\site-packages\wfastcgi-3.0.0-py3.8.egg\wfastcgi.py" resourceType="Unspecified" requireAccess="Script" />
</handlers>
<security>
<authentication>
<windowsAuthentication enabled="true" />
<anonymousAuthentication enabled="false" />
</authentication>
</security>
</system.webServer>
<appSettings>
<add key="PYTHONPATH" value="C:\inetpub\wwwroot\flaskr" />
<add key="WSGI_HANDLER" value="__init__.app" />
<add key="WSGI_LOG" value="C:\inetpub\wwwroot\flaskr\wfastcgi.log" />
</appSettings>
</configuration>