Server Error in Application? Fix It Now
In this article
If you see "Server Error in Application" in your browser, the web application you are trying to use has crashed or is misconfigured. This error is most common on ASP.NET applications running on Windows servers, and the fix usually involves checking the server's error logs, reviewing the web.config file, or restarting the application pool.
What This Error Actually Means
The "Server Error in Application" message is a generic ASP.NET error page that appears when an unhandled exception occurs. It is the default response when the application's customErrors mode is set to Off or RemoteOnly, and the server has no friendly error page configured. The full message usually includes a path like "/" and a specific exception type, such as SqlException, HttpException, or NullReferenceException.
This error is not the same as a 404 (page not found) or 500 (internal server error) that you might see on other platforms. It is specific to Microsoft's ASP.NET framework and indicates that the .NET runtime on the server threw an exception that was not caught by the application's code. The error page often contains a yellow background with black text, showing the exception details, the source file, and the stack trace.
Common Causes
Several issues can trigger this error, and identifying the root cause is the first step to fixing it. The most frequent causes include:
- Configuration errors in web.config – A malformed XML tag, an invalid connection string, or a missing assembly reference can crash the application on startup.
- Database connection failures – If the application cannot reach its SQL Server or other database, it will throw an exception when trying to query data.
- Missing files or permissions – The application may be referencing a file (like an image, DLL, or log) that does not exist, or the application pool identity may not have read/write permissions to the folder.
- Application pool recycling or crash – If the IIS application pool stops due to rapid-fail protection or a memory limit, the next request will show this error.
- Code exceptions – Unhandled exceptions in the application's code, such as trying to access an object that is null, are a common cause.
How to Diagnose the Exact Problem
Before making changes, you need to see the detailed error message. By default, the error page may hide details from remote users. To see the full exception, you can temporarily edit the web.config file on the server:
- Open the
web.configfile in a text editor. - Locate the
<system.web>section. - Change or add:
<customErrors mode="Off" /> - Save the file and refresh the page. The full error details will now appear.
If you cannot edit the file, check the Windows Event Viewer under Windows Logs > Application. Look for entries from ASP.NET or .NET Runtime that contain the exception stack trace. You can also enable Failed Request Tracing in IIS to log detailed information about each request.
Step-by-Step Fixes to Try
Once you have the specific error message, apply the appropriate fix. Here are the most common resolutions:
- Restart the application pool – In IIS Manager, go to Application Pools, find the pool for your site, right-click it, and select Recycle. This clears any stuck state.
- Check the connection string – Verify that the database server name, credentials, and database name in the
connectionStringssection of web.config are correct. Test the connection using SQL Server Management Studio or a simple .NET script. - Fix file permissions – Ensure the application pool identity (usually
IIS AppPool\YourPoolName) has read access to the application folder and write access to any folders that need it (likeApp_Dataor logs). - Validate web.config – Use an XML validator to check for syntax errors. A common mistake is a missing closing tag or an unescaped ampersand (& instead of &).
- Check for missing DLLs – If the error mentions a missing assembly, ensure the
binfolder contains all required DLLs, or runnuget restoreif you have the source code. - Review the stack trace – The stack trace will point to the exact line of code that threw the exception. Fix that code, or add a try-catch block to handle the error gracefully.
Preventing Future Errors
Once the immediate issue is resolved, take steps to prevent it from happening again:
- Set customErrors to RemoteOnly – This shows detailed errors to local users (developers) but generic messages to remote visitors, hiding sensitive information.
- Add a global error handler – In the
Global.asaxfile, implement theApplication_Errorevent to log exceptions and redirect users to a friendly error page. - Monitor application pool health – Configure recycling based on memory limits or time, and enable Rapid Fail Protection to avoid repeated crashes.
- Use a staging environment – Test code changes on a non-production server before deploying to live.
Differences from Other Server Errors
It is helpful to know how this error differs from similar ones. A 500 Internal Server Error is a generic HTTP status code that can come from any server technology. The "Server Error in Application" is a specific ASP.NET rendering of that status. A 503 Service Unavailable usually means the application pool is stopped or the server is overloaded. A 404 means the URL does not exist, not that the application crashed. Understanding these distinctions helps you communicate the problem to your hosting provider or system administrator.
When to Contact Your Hosting Provider
If you have tried the steps above and still see the error, it may be a server-level issue outside your control. Contact your hosting provider if:
- You do not have access to IIS Manager or the server file system.
- The error occurs on a shared hosting plan where you cannot edit web.config or application pool settings.
- The error appears for all sites on the server, indicating a global .NET installation problem.
Provide them with the full error message, the time it occurred, and any recent changes you made. Most providers can check the server logs and restart the application pool for you.
Frequently Asked Questions
Why do I see this error only sometimes?
Intermittent errors are often caused by application pool recycling, database timeouts, or memory pressure. When the pool recycles, the first request after that may fail if the application takes too long to start. Check the application pool settings and increase the startupTimeLimit if needed.
Can this error be caused by a bad plugin or theme?
Yes, if you are using a CMS like Umbraco or Sitefinity, a faulty plugin or theme can throw an unhandled exception. Disable recently installed plugins and see if the error disappears. Review the error log to identify which module is causing the issue.
Is it safe to show detailed errors to the public?
No. Detailed error messages can expose file paths, database connection strings, and code structure, which hackers can use to attack your site. Always set customErrors to RemoteOnly or On in production, and create a custom error page that does not reveal sensitive information.
How do I create a custom error page for this error?
In the web.config file, under <system.web>, add a <customErrors> section with a defaultRedirect attribute pointing to a friendly page, like defaultRedirect="~/Error.aspx". You can also specify different pages for specific status codes using <error> elements.
Will restarting the server fix this error?
Sometimes, but it is a temporary fix. If the underlying cause is a code bug or misconfiguration, the error will return after the next request. Restarting the server or application pool should be a last resort, not a permanent solution.