WebHost failed to process a request AND SQL database login for Config on instance SQL failed

After setting up my SharePoint 2013 for both Web Front End Server and Application Server. I encountered the following error in my WFE server

Source: System.ServiceModel 4.0.0.0

Task Category: WebHost

Event ID: 3

[sourcecode]

WebHost failed to process a request.
Sender Information: System.ServiceModel.ServiceHostingEnvironment+HostingManager/63835064
Exception: System.ServiceModel.ServiceActivationException: The service ‘/SecurityTokenServiceApplication/securitytoken.svc’ cannot be activated due to an exception during compilation. The exception message is: Exception has been thrown by the target of an invocation.. —> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> System.InvalidOperationException: The farm is unavailable.
at Microsoft.SharePoint.Administration.Claims.SPSecurityTokenServiceManager.get_Local()
at Microsoft.SharePoint.IdentityModel.SPSecurityTokenServiceConfiguration..ctor()
— End of inner exception stack trace —
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture)
at Microsoft.IdentityModel.Protocols.WSTrust.WSTrustServiceHostFactory.CreateSecurityTokenServiceConfiguration(String constructorString)
at Microsoft.IdentityModel.Protocols.WSTrust.WSTrustServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses)
at Microsoft.SharePoint.IdentityModel.SPSecurityTokenServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath, EventTraceActivity eventTraceActivity)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity)
— End of inner exception stack trace —
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity)
at System.ServiceModel.ServiceHostingEnvironment.EnsureServiceAvailableFast(String relativeVirtualPath, EventTraceActivity eventTraceActivity)
Process Name: w3wp
Process ID: 4844

[/sourcecode]

TOGETHER with

Source: SharePoint Foundation

Task Category: Database

Event ID: 3351

[sourcecode]

SQL database login for ‘SHAREPOPINT CONFIG DB NAME’ on instance ‘SQL INSTANCE NAME’ failed. Additional error information from SQL Server is included below.

Login failed for user ‘Web Front End SERVERNAME$’.

[/sourcecode]

The reason why i mentioned these two events are together is that the resolution below that i did is related to the two error events. If your event log does not contain these two errors, it is likely that the resolution below may not work for you.

Resolution

  1. Go to the server that contain these error message (Web Front Event server).
  2. Open IIS (Internet Information Services) Manager
  3. In the Connections panel, navigate to Application Pools
  4. (In my case, the “SecurityTokenServiceApplicationPool” Application Pool is running using “LocalSystem” account)
  5. Select the SecurityTokenServiceApplicationPool and click “Advanced Settings” from the action panel.
  6. Scroll to ProcessModel section and change the Identity to YOUR SharePoint Farm Account!
  7. Click Ok and Recycle the application pool and done!