Click here to Skip to main content
15,889,992 members
Articles / .NET / .NET Core

How Do I Fix HTTP Error 502.5 - Process Failure When Hosting in IIS with .NET Core

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
13 May 2018MIT1 min read 34.7K   3   3
How to fix "HTTP Error 502.5 - Process Failure" error

I received a new error today that I haven't received before when deploying dotnet core apps. It was as the title suggested an "HTTP Error 502.5 - Process Failure" error.

image

None of the suggestions had any effect and hours of Googling also didn't help either until eventually, I came across a solution that worked.

The Solution

I eventually found a solution on the aspnet / Hosting repo on GitHub on issue number #1234 (funny enough, it feels made up, but isn't). jdownie posts the following solution:

Man! I finally worked this one out (in my instance) and I found that web.config had 
processPath="dotnet". I had to go into cmd.exe to run where.exe (because that means 
something else in powershell now) and located dotnet in C:\Program Files\dotnet\dotnet.exe.
I then set processPath="C:\Program Files\dotnet\dotnet.exe" and voila! Mind you, I 
had changed about 500 other things trying to work it out, so there might have been 
other factors at play. Just posting what I found FWIW.

Although that solution worked for me, it wasn't good enough. The problem here is that I deploy everything through TFS or VSTS so I couldn't just manually set the value.

My Solution

Although hacky, my solution works for me. Similar to how the solution above worked for jdownie Smile. I'm lucky enough to be able to place an agent on my web server so I can run this method otherwise unzipping, hard coding the value from the build server and zipping up the publish package can also work.

Basically what I have done is after I web deploy, I have a final phase which checks the machine Paths environment variable and sets the processPath to the first path it finds that contains dotnet.exe in it.

param([Parameter(Mandatory=$True)][string]$config)

if (-not (Test-Path -LiteralPath $config))
{
	Write-Host "##vso[task.logissue type=warning;]No web.config found at '$($config)'."
}
else
{
	Write-Output "Loading config file from $($config)"
	$xml = [xml](Get-Content $config)
    	$Paths = [Environment]::GetEnvironmentVariable("Path","MACHINE").Split(';')
	$DotNetPath = ""
	foreach($Path in $Paths)
	{
		$DotNetPath = "$($Path)dotnet.exe"
		if (Test-Path -LiteralPath $DotNetPath)
		{
			break
		}
	}
	if (-not (Test-Path -LiteralPath $DotNetPath))
	{
		Write-Host "##vso[task.logissue type=error;]can't find dotnet.exe."
	}
    	$xml.configuration.'system.webServer'.aspNetCore.SetAttribute("processPath",$DotNetPath)
	$xml.Save($config)
}

Now on every deploy, I have a running site that is guaranteed to have a valid dotnet.exe value.

image

and I guess more importantly, a running site: Smile with tongue out

image

Conclusion

.NET Core although getting mature, is not quite there in all aspects and you are going to hit some issues with it that you wouldn't expect.

The great thing about this is the support from the community and Microsoft is brilliant and the decision to go .NET Core would not be a bad one Open-mouthed smile.

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
Architect SSW
South Africa South Africa

Comments and Discussions

 
QuestionThank you Pin
Member 124139415-Dec-18 22:43
Member 124139415-Dec-18 22:43 
QuestionSame Error, The Fix Pin
Gfw13-May-18 23:57
Gfw13-May-18 23:57 
AnswerRe: Same Error, The Fix Pin
Gfw14-May-18 23:01
Gfw14-May-18 23:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.