Loading...

How to Fix a SharePoint 404 Error After Restoring a Content Database

SharePoint 404 Error (After restoring a previous copy of a content database to replace the current one)

A 404 error in SharePoint can mean multiple things. In this case, it happens because we restored an older version of a content database to resolve an issue. Now when we go to the site we get a 404 (even after an iisreset).

SharePoint 404 Error

Basically we will want to clear the local SharePoint config cache on all of the front end servers.  There is a cache.ini file and several xml files generated by SharePoint.  We will be resetting the cache.ini file to 1 and deleting all of the XMLfiles.  SharePoint will then start rebuilding.

Stop SharePoint Timer Service

The first step will be to stop SharePoint timer service.  This will prevent SharePoint from rebuilding the cache before we have a chance to delete all of the XML files.  If you are fast enough this is not necessary, but it is a good idea to perform this step.

SharePoint Cahe Directory

Next we need to navigation to “c:\PogramData\Microsoft\SahrePoint\Config”.  Make sure you can see hidden directories and file extensions to make things easier.

Incorrect Directory for Cache

Wrong Directory

Open SharePoint Cache

Right Directory

Now we need to find the right directory.  Because these are generated by SharePoint, they will not have the same names every time.  We can tell if it is the right directory if it has a cache.ini file and several XML files (in some cases several thousand or more).

Now open the cache.ini file in notepad

Delete all XML files

Select all of the XML files and delete them.

Set the cache.ini file to 1 and save it.

Start SharePoint Timer Service

Now we can start the SharePoint Timer Service back up. You will see the directory begin to fill back up with XML files. Do the same for the other frontends, and you should be able to see the site without the 404 error.

A TechNet blog has a great PowerShell script that can be used instead of the manual method (http://blogs.technet.com/b/sp/archive/2013/05/29/clear-sharepoint-config-cache-with-powershell.aspx):

Add-PSSnapin -Name Microsoft.SharePoint.PowerShell –erroraction SilentlyContinue
Stop-Service SPTimerV4
$folders = Get-ChildItem C:\ProgramData\Microsoft\SharePoint\Config
foreach ($folder in $folders)
{
$items = Get-ChildItem $folder.FullName -Recurse
foreach ($item in $items)
{
if ($item.Name.ToLower() -eq “cache.ini”)
{
$cachefolder = $folder.FullName
}}
}
$cachefolderitems = Get-ChildItem $cachefolder -Recurse
foreach ($cachefolderitem in $cachefolderitems)
{
if ($cachefolderitem -like “*.xml”)
{
$cachefolderitem.Delete()
}}$a = Get-Content $cachefolder\cache.ini
$a = 1

Set-Content $a -Path $cachefolder\cache.ini
read-host “Do this on all your SharePoint Servers – and THEN press ENTER
start-Service SPTimerV4

If you’ve determined that you need to delete your site, but can’t use the usual methods, see Part 2 on how to delete that site collection.

By | 2017-06-05T17:38:48+00:00 October 16th, 2015|Categories: Enterprise IT, SharePoint Solutions|Tags: , , |

About the Author:

Ricardo is MetroStar's thought leader and subject matter expert for enterprise collaboration software. He has been providing MetroStar's customers with innovative collaboration and integration options for 10 years.