HTTP错误503。服务不可用。应用程序池在访问网站时停止

有很多关于这个的帖子,我现在已经尝试了很多东西。但无济于事。我自己基本上是一名WinForms开发人员,几天前我的公司正在采取网络计划时,我就开始从事这项网络工作。

我有一个ASP.NET项目,我想在本地IIS上托管它。在Project properties -> Web设置中,我选择了Use Local IIS Server,并给出了一个URL作为localhost/MyApp。我尝试在我的火狐浏览器上访问它,并收到HTTP Error 503. The service is unavailable.的错误。

以前我有很多其他的错误,我一个接一个地修复了它们。但被这个击中了。这些是我的项目中的设置

  1. 应用程序池设置为ASP.NET V4.0 Classic
  2. 应用程序池Enable 32 bit Application属性为True
  3. 应用程序池已启动
  4. 对于目标框架,“项目生成”属性设置为Any CPU

但我想提一个奇怪的行为。以下是我所面临的问题

  1. 应用程序池已启动
  2. 我尝试访问我的本地网站(通过将URL指定为localhost/MyApp
  3. 我收到的错误是HTTP Error 503. The service is unavailable
  4. 应用程序池已停止

我看过下面的链接,我已经试过了。对于上述行为,我达到了在这里。根据此链接,计算机名称中不应包含.。我的计算机名中没有任何.,但有-。此外,我的域名包含.。此外,我无法更改这些设置,因为这是我办公室的笔记本电脑,我们的TFS设置绑定到我们的域名和计算机名称。

有人能帮我了解发生了什么吗?请指导我。谢谢。

编辑

我在Global.asax中有以下代码。Application_BeginRequest方法在同一文件中是空的。

protected override void Application_Start(object sender, EventArgs e)
{
base.Application_Start(sender, e);
String _path = String.Concat(System.AppDomain.CurrentDomain.RelativeSearchPath, ";",
System.Environment.GetEnvironmentVariable("PATH"));
System.Environment.SetEnvironmentVariable("PATH", _path, EnvironmentVariableTarget.Process);
MyAppLog.Initialize();
MyAppLog.WriteMessage("Application Started");
}

更新

根据评论中的建议,我可以从卡西尼运行网站。

320720 次浏览

One possible reason this might happen is that the Application Pool in IIS is configured to run under some custom account and this account either doesn't exist or a wrong password has been provided, or the password has been changed. Look at the advanced properties of the Application Pool in IIS for which account it uses.

Also the Event Log might contain more information as to why the Application Pool is stopping immediately on the first request.

enter image description here

I was facing the same problem, and debugged it using the event logs. First it said that : "The description for Event ID 5059 from source Microsoft-Windows-WAS cannot be found".

I then turned on WAS using turn windows features on/off. Then i saw this in eventvwr "Microsoft-Windows-DistributedCOM cannot be found".

Finally I gave up and deleted the App Pool (that used to stop on accessing the website) and created it again, as it is. This resolved the problem.

If you have McAfee HIPS and if you see the following error in event viewer application log:

The Module DLL C:\Windows\System32\inetsrv\HipIISEngineStub.dll failed to load.
The data is the error.

Then the following resolved the issue in my case: https://kc.mcafee.com/corporate/index?page=content&id=KB72677&actp=LIST

Quote from the page:

  1. Click Start, Run, type explorer and click OK.
  2. Navigate to: %windir%\system32\inetsrv\config
  3. Open the file applicationHost.config as Administrator for editing in Notepad.
  4. Edit the <globalModules> section and remove the following line:
    <add name="MfeEngine" image="%windir%\System32\inetsrv\HipIISEngineStub.dll" />

  5. Edit the <modules> section and remove the following line:
    <add name="MfeEngine" />

  6. After you have finished editing the applicationHost.config file, save the file, then restart the IIS server using iisreset or by restarting the system.

I had a similar issue, all my app pools were stopping whenever a web request was made to them. Although I was getting the following error in the Event Viewer:

The worker process for application pool 'appPoolName' encountered an error 'Configuration file is not well-formed XML ' trying to read configuration data from file '\?\C:\inetpub\temp\apppools\appPoolName\appPoolName.config', line number '3'. The data field contains the error code.

Which told me that there were errors in the application.config at:

C:\Windows\System32\inetsrv\config\applicationHost.config

In my scenario, I edited the web.config on deploy with an element IIS clearly dislikes, the applicationHost.config scraped the web.config and inserted this bad element and wouldn't resolve until I manually removed it

For my situation is that my login password changed, while the application pool still uses the old one. So just click the "Advanced Settings" of your application pool and reset your "Identity".

If you can run the website in Visual Studio debugger, then might be able to see where in your code the application pool is crashing. In my case, it was a function being called recursively an unlimited number of times, and that caused a stack overflow. Note: the Windows event log and the IIS logs were not helpful to diagnose the problem.

I had a similar issue. I solved it by adding my user to the "Log on as a batch job" policy under "Local Security Policy" > "Local Policies" > "User Rights Assignment".

When I first time add the service and created the app pool for it. I did "iisreset" from command prompt, and it worked.

In addition to the steps outlined at this link from Orhan's answer, you may need to additionally remove the native module by going to IIS Manager > Server Root > Modules > Configure Native Modules. Select MfeEngine and then select Remove.

I was experiencing this error and in my case the cause was that some time ago I modified the user password, and the 503 error didn't appears till I restarted the application pool.

So I fixed it setting the new password on Applications Pools / Advanced Settings / Identity / [...] / Set... / Password / Confirm Password

I had the same issue with iis 8.5. After searching the eventViewer under windows Logs-->applications, I realized that I'm having a permission error for the machine.config file of the .net framework located at "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config". Giving it a permission for IIS_IUSRS solved my problem (right click the file-->properties-->security-->edit-->add-->IIS_IUSRS)

Most of Time, it was occured due to AppPool Setting.

Check the following to resolve this

  1. Check Apppool service is running.
  2. Check Identity of AppPool.
  3. Enter the new password if it has changed for that identity.

The following Images show these setting in IIS

enter image description here

For anyone coming here with Windows 10 and after updating them to Anniversary update, please check this link, it helped me:

https://orcharddojo.net/blog/troubleshooting-iis-apppool-crashes-status-503-after-windows-10-anniversary-update

In case link goes down: If your Event log shows that aspnetcore.dll, rewrite.dll (most often, but could be others as well) failed to load, you have to repair the missing items.

Here are two specific issues we've experienced so far and how to fix them, but you may bump into completely different ones:

"C:\WINDOWS\system32\inetsrv\rewrite.dll" (reference)
Go to "Programs and Features" (Win+X, F) and repair "IIS URL Rewrite Module 2".
"C:\WINDOWS\system32\inetsrv\aspnetcore.dll" (reference)
Go to "Programs and Features" (Win+X, F) and repair "Microsoft .NET Core 1.0.0 - VS 2015 Tooling ...".

Ok, I have another solution for one specific case: if you use WINDOWS 10, and you updated it recently (with Anniversary Update package) you need to follow the steps below:

  1. Check your Windows Event Viewer - press Win+R and type: eventvwr, then press ENTER.
  2. On the left side of Windows Event Viewer click on Windows Logs -> Application.
  3. Now you need to find some ERRORS for source IIS-W3SVC-WP in middle window.
  4. Probably you will see message like:

The Module DLL >>path-to-DLL<< failed to load. The data is the error.

  1. You have to go to Control Panel -> Program and Features and depending on which dll cannot be load you need to repair another module:
    • for rewrite.dll - find IIS URL Rewrite Module 2 and click Change->Repair
    • for aspnetcore.dll - find Microsoft .NET Core 1.0.0 - VS 2015 Tooling ... and click Change->Repair.
  2. Restart your computer.

In my case I checked event logs and found error was Cannot read configuration file ' trying to read configuration data from file '\\?\', line number '0'. The data field contains the error code.

The error code was 2307.

I deleted all files in C:\inetpub\temp\appPools and restarted the iis. It fixed the issue.

Just to add to these Anniversary Update issues (thanks Microsoft) if the file you are missing is cgi.dll, ie your Event Viewer has

The Module DLL C:\WINDOWS\System32\inetsrv\cgi.dll failed to load.  The data is the error.

Then to fix this:

  1. Go to IIS Manager
  2. Select the very top row in the Connections panel (typically your PC name)
  3. At the very bottom of the right panel, under Management, you should have Web Platform Installer
  4. Once that loads, select Products
  5. In the search type in cgi then hit <Enter>
  6. Select IIS: CGI then click Add on the right and finally Install on the bottom
  7. After installing it should force you to restart your PC and you should be fixed.

Changing "Managed Pipeline Mode" from "Classic" to "Integrated" worked for me. It can be changed at Application Pools -> Basic Settings

Will this answer Help you?
If you are receiving the following message in the EventViewer

The Module DLL aspnetcorev2.dll failed to load. The data is the error.

Then yes this will solve your problem


To check your event Viewer

  1. press Win+R and type: eventvwr, then press ENTER.
  2. On the left side of Windows Event Viewer click on Windows Logs -> Application.
  3. Now you need to find some ERRORS for source IIS-W3SVC-WP in the middle window.

if you receiving the previous message error then solution is :

Install Microsoft Visual C++ 2015 Redistributable 86x AND 64X (both of them)

Source

One possible reason this might happen is that you don't have enough disk space in your server machine. You can find more information in event viewer. if such thing happen, just stop the IIS, clean some free disk space and restart the IIS and then start the App Poll. enter image description here

In my case error message displaed in Windows Event Viewer -> Windows Logs -> Application was "The Module DLL C:\Windows\system32\inetsrv\rewrite.dll failed to load. The data is the error." Uninstalling rewrite module via installer solved the problem. I wasn't using any rewrite rules so I uninstalled rewrite module. Reinstalling the module may help the problem as well.

To Fix the problem, Follow the steps as I faced the same issue and below solution worked for me

1- Give full Rights or at least read access rights of Folder "C:\inetpub\temp" to IIS_IUSRS

2- also check same rights given to User IIS_IUSRS of folder "C:\inetpub\wwwroot".

hope this solution works!

I just had this issue on some legacy servers running Windows 2008 R2. 32bit applications would crash the app pool and return a 503 without hitting the app code. The problem seems to be related to .net core module erroneously trying to load the 64bit version of the module even though the 32bit application in question was not a .net core app.

It seems that IIS still loads the module when figuring out which module to load to service the request and trying to load a 64bit version into a 32bit process is no bueno.

In the end, I had to uninstall all versions of .net core from the server and reinstall the latest (at this time 3.1.15- we're not using 5 yet). After that my 32bit apps and .net core apps could coexist on the same server.

This is the blog post that helped me resolve this after days of banging my head on it. Hopefully it helps someone out. Blog post with the solution

Give full Rights rights to Folder "C:\inetpub" Work for me!

Such 503 errors were encountered on our side on Windows Server 2019 while setting up a fresh new Classic ASP website.

In fact, in the App Pool, setting ".NET CLR Version" to "No Managed code" caused the App Pool to stops 2 seconds after being started, thus generating WAS 5002 and 5021 errors in the Windows Event Log.

The solution was to put "v4.0", even if no .NET is used.

I'm late to the party, but the solution that worked for me isn't listed.

The solution for me was simply to delete the web site and application pool within IIS, and re-create them.

This is because originally I had create the site/folder first, then installed the dotnet core runtime. For some reason this failed to allow the site to start up.

Once re-created, the site came to life with none of the other suggestions being required.

In my case, the web sites displayed "503 Service unavailable" and the application event log showed "...\aspnetcorev2.dll failed to load. The data is the error." This only happened for IIS sites where where the IIS setting "Enable 32-Bit Applications" was True. The system was stopping the app pools for these sites, which is what generated the "503 Service unavailable" message when trying to retrieve the site.

It turns out the path specified in this application event log didn't even exist. Trying to repair the two "Microsoft.NET Core SDK 2.1.50x" versions installed on the system didn't resolve the issue, nor did installing the latest and only aspnetcorev2.dll that Microsoft seems to have available, nor did uninstalling these SDKs.

NOTE: Microsoft doesn't even seem to have the installers available anymore for the original v2 ASP.NET Core versions that had been installed on my system.

What worked: Since I don't have any ASP.NET Core sites on this system, the solution that worked for me was to uninstall all the related DLLs from my system and to remove them from the IIS applicationhost.config file by commenting them out (see aspnetcore.dll failed to load and applicationhost.config file path in IIS 7, 7.5, 8, 8.5 and IIS 10?). If you do use a later version of ASP.NET Core, I'd think you could just as well update the references in applicationhost.config [I haven't tried that].