Friday, June 13, 2014

Service Unavailable: HTTP Error 503. The service is unavailable. - Your Application + SSRS + Reports folder = obscure mess

Introduction

Wow... another error message that tells you NOTHING!
This error message reads:
Service Unavailable: HTTP Error 503. The service is unavailable.
I need to start off by saying that 503 errors can happen for a potpourri of reasons. This is by no means a silver bullet or all encompassing solution, this is for a very specific scenario which is very vague, frustrating, infuriating and both an obscure problem & gotcha! This error will be going into my "Application Errors Hall of Shame". When you have a 503 error chances are your application isn't going to even break on a break point. Sometimes this is due to code blowing up prematurely before Page_Load is even reached, other times it can be windows taking a crap, in which case a restart can fix that. Then there are problems like this one.

I was scouring google for an answer about this problem, when I found a very striking similarity that my problem had with a post I found. We had the exact same problem and the folder name involved was not a coincidence, it couldn't be - it was too exact. On to the stupid problem!

The Stupid Problem

When I would try to access my reports folder from my application I was met with the above 503 error for no obvious reasons I could think of. Example: http://myApplication/Reports/someReport.aspx
Keep your focus on the fact that I have a folder named "Reports". I tried the following until I found the solution:

  • Added a dummy file (test.txt) to the directory and tried to access it - did not work
  • Reset permissions on the folder - did not work
  • Removed site and application pool from IIS - did not work
  • Made a copy of the directory and changed the name - it worked??? Why? This indicates that there is a conflict on that virtual directory. When I checked IIS, I did not see this directory listed anywhere. WTF?

The Jaw Dropping Answer to the Stupid Problem

So... Do you have SSRS installed on the machine where you are having this problem? If you do have SSRS installed on your machine, move to the next section. If you do not - I can't promise I have an answer for you, but I can give you some hints - go to the last section.

I have SSRS installed

Oh you are in for a treat. It turns out that SSRS's default virtual directory is also named "Reports". If you have the SSRS service turned off, you will get a 503 error. If you do not have it turned off you will be prompted to login - which should be confusing, because it is out of place. Therefore in order to fix this specific 503 error, you must do the following:
  1. Open up the "Reporting Services Configuration Manager". You can navigate here via: "Start > Microsoft SQL Server 2008 R2 > Configuration Tools" - I'm assuming you are using SQL Server 2008 R2, even if you are not, it should be the same idea. [Figure 1]
  2. Turn on the SSRS service if it is not started already. This is temporary, you can turn it off again when finished.
  3. Click on "Report Manager URL" on the side bar. Sometimes it takes a little while to load, just wait. [Figure 2]
  4. Take this moment to be upset because I know I was - you will see that the Report Manager URL clearly says it is "Reports". This is not a coincidence, this is what is causing the conflict regardless of whether the service is running or not [Figure 2]
  5. Change the name to something else. I changed mine to "ReportsForMfingSSRS_StupidConflict" - that way this never happens again.
  6. Optional - stop the service again. I keep mine off for the most part.
  7. Rejoice
Figure 1: Opening up the Reporting Services Configuration Manager
Figure 2: SSRS Virtual Directory is named Reports!

I do not have SSRS installed

If you do not have SSRS installed then your problem is being caused by something else obviously. I have some suggestions, but once again these suggestions may not work - but it is worth a shot:
  1. Put a break point in your Global.asax.cs on the "Application_Error" event - this can sometimes help. This event is triggered when you do not handle your exceptions on your page. This is when you would get a "Yellow Screen of Death". If you do not get to this point, either the exception is being handled or your application is never being hit which means there is an external problem such as the above example with SSRS. There is interference.
  2. An internal windows service has stopped running properly and is causing bogus ass problems. Restart your computer. If that doesn't work then it could still be code.
  3. Referring to the page that is giving you a problem, look at your global variables on that page. If you have global variables being instantiated outside of the "Page_Load" event or other place - then those objects could be the cause of your problems. I had a problem where the constructor of one of my objects which happened to be a global variables was blowing up on instantiation. This wouldn't even let me get to page load, I would just get the 503 error. However - my Global.asax.cs would catch the error! Go to suggestion 1 for more debugging. 
If none of those suggestions help, then you need to keep digging - i'm sorry. Just try to be patient and work through it. The SSRS bug took me 3 hours to figure out.

Sources

My search brought up a lot of articles, but really only one post is what worked for me. The answer is at the bottom and there were no instructions.

4 comments:

  1. This helped out thanks for the post

    ReplyDelete
  2. Finally my several hours of searching online paid off. Thank you so much.

    ReplyDelete
    Replies
    1. I know how you feel and that's why I run this blog - you are very welcome.

      Delete
  3. changing the service name from Reports worked. Thanks a ton
    your report name - ReportsForMfingSSRS_StupidConflict is epic BTW

    ReplyDelete