HTTP Error 503. The service is unavailable.

Issue:

I’m getting an error 503 when visited a newly created site in IIS with AppPool account. Is it error in my code?

Service Unavailable
HTTP Error 503. The service is unavailable.

Environment:

Windows 2012 R2, IIS 8.5, ASP.Net

Resolution:

This error happened usually is because app pool is down. To start an app pool service, please follow following steps.

Step-by-step instructions:-

  1. Open IIS Manager on your web server
  2. Browse to “Application Pools”
  3. Verify app pool status by checking status column next to app pool name that is being used by the app
  4. Right click on app pool name and select “Start” to start app pool service
  5. Go to web browser and check if the application is up and running

Troubleshoot:

For ASP.Net project, is always good idea to turn off custom error on development server. Do not  turn off custom error on production server to avoid security risk. To turn custom error off, change mode to “Off” on web.config:

<customErrors mode="Off" />

 

Object already exists when trying to use aspnet_regiis to encrypt web.config connectionStrings section

Issue:

When I tried to encrypt my web.config connectionStrings section with aspnet_regiis, I got an error message saying Object already exists. What happen?

Administration utility to install and uninstall ASP.NET on the local machine.
Copyright (C) Microsoft Corporation.  All rights reserved.
Encrypting configuration section...
An error occurred executing the configuration section handler for connectionStrings.


Failed to encrypt the section 'connectionStrings' using provider 'MyIisRsaProv'. Error message from the provider: Object already exists.


Failed!

Environment:

Windows 10, .Net Framework v4.0.30319, PowerShell ISE or Command Prompt

Resolution:

In order to run aspnet_regiis to encrypt configuration section(s), you need to run PowerShell ISE or Command Prompt with Run as administrator

Step-by-step instructions:-

  1. Click on search on your Windows 10 machine and type powershell or command prompt

  2. Right click on Windows PowerShell ISE and select “Run as administrator”
  3. Enter your encryption command and run, ex., C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -pef connectionStrings c:\temp\ -prov MyIisRsaProv
  4. You should get succeed result as below:

    Microsoft (R) ASP.NET RegIIS version 4.0.30319.0

    Administration utility to install and uninstall ASP.NET on the local machine.

    Copyright (C) Microsoft Corporation. All rights reserved.

    Encrypting configuration section...

    Succeeded!

Troubleshoot:

If you still having problem, make sure you run PowerShell or Command Prompt as Administrator by checking Window Title:
 

Reference:

Sample PowerShell to encrypt existing configuration sections:

        $app_path = "c:\your\Web.Config\folder"
        Write-Host "> connectionStrings"
        $bol_encrypt_config_here = 0
        Get-Content $app_path\web.config | ForEach-Object {if($_ -match "connectionStrings"){ $bol_encrypt_config_here = 1 }}
        if($bol_encrypt_config_here) { C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis -pef connectionStrings $app_path -prov MyIisRsaProv }
       
        Write-Host "> machineKey"
        $bol_encrypt_config_here = 0
        get-content $app_path\web.config | foreach-object {if($_ -match "machineKey"){ $bol_encrypt_config_here = 1 }}
        if($bol_encrypt_config_here) { c:\windows\microsoft.net\framework\v4.0.30319\aspnet_regiis -pef system.web/machineKey $app_path -prov MyIisRsaProv }
       
        Write-Host "> sessionState"
        $bol_encrypt_config_here = 0
        get-content $app_path\web.config | foreach-object {if($_ -match "sessionState"){ $bol_encrypt_config_here = 1 }}
        if($bol_encrypt_config_here) { c:\windows\microsoft.net\framework\v4.0.30319\aspnet_regiis -pef system.web/sessionState $app_path -prov MyIisRsaProv }
       
        Write-Host "> appSettings"
        $bol_encrypt_config_here = 0
        get-content $app_path\web.config | foreach-object {if($_ -match "appSettings"){ $bol_encrypt_config_here = 1 }}
        if($bol_encrypt_config_here) { c:\windows\microsoft.net\framework\v4.0.30319\aspnet_regiis -pef appSettings $app_path -prov MyIisRsaProv }