title: System.ComponentModel.Win32Exception: The wait operation timed out from Azure VPN
body: <p><a href="https://i.stack.imgur.com/woKIs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/woKIs.png" alt="enter image description here"></a>We have a Azure app service which tries to connect to on premise SQL server using 
  VPN classic(configured using VNET). </p>
  
  <p>Occasionaly we get the following error :</p>
  
  <p>System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - The wait operation timed out.) ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out</p>
  
  <p>at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling)</p>
  
  <p>at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)</p>
  
  <p>at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)</p>
  
  <p>at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)</p>
  
  <p>at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)</p>
  
  <p>at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal&amp; connection)</p>
  
  <p>at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal&amp; connection)</p>
  
  <p>at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal&amp; connection)</p>
  
  <p>at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)</p>
  
  <p>at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)</p>
  
  <p>at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)</p>
  
  <p>at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)</p>
  
  <p>at System.Data.SqlClient.SqlConnection.Open()</p>
  
  <p>at Dapper.SqlMapper.d__11`1.MoveNext()</p>
  
  <p>at System.Collections.Generic.List<code>1..ctor(IEnumerable</code>1 collection)</p>
  
  <p>at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)</p>
  
  <p>at Dapper.SqlMapper.Query[T](IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable<code>1 commandTimeout, Nullable</code>1 commandType)</p>
  
  <p>at SiSystems.ClientApp.Web.Domain.Repositories.UserRepository.FindByPrimaryEmail(String username)</p>
  
  <p>at SiSystems.ClientApp.Web.Domain.Repositories.UserRepository.FindByName(String username)</p>
  
  <p>at SiSystems.ClientApp.Web.Auth.UserStore.&lt;>c__DisplayClass3_0.b__0()</p>
  
  <p>at System.Threading.Tasks.Task`1.InnerInvoke()</p>
  
  <p>at System.Threading.Tasks.Task.Execute()</p>
  
  <p>--- End of stack trace from previous location where exception was thrown ---</p>
  
  <p>at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)</p>
  
  <p>at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)</p>
  
  <p>at Microsoft.AspNet.Identity.TaskExtensions.CultureAwaiter`1.GetResult()</p>
  
  <p>at Microsoft.AspNet.Identity.UserManager`2.d__12.MoveNext()</p>
  
  <p>--- End of stack trace from previous location where exception was thrown ---</p>
  
  <p>at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)</p>
  
  <p>at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)</p>
  
  <p>at SiSystems.ClientApp.Web.Auth.ApplicationOAuthProvider.d__2.MoveNext()</p>
  
  <p>--- End of stack trace from previous location where exception was thrown ---</p>
  
  <p>at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)</p>
  
  <p>at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)</p>
  
  <p>at Microsoft.Owin.Security.OAuth.OAuthAuthorizationServerHandler.d__3f.MoveNext()</p>
  
  <p>--- End of stack trace from previous location where exception was thrown ---</p>
  
  <p>at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)</p>
  
  <p>at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)</p>
  
  <p>at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)</p>
  
  <p>at Microsoft.Owin.Security.OAuth.OAuthAuthorizationServerHandler.d__22.MoveNext()</p>
  
  <p>--- End of stack trace from previous location where exception was thrown ---</p>
  
  <p>at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)</p>
  
  <p>at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)</p>
  
  <p>at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)</p>
  
  <p>at Microsoft.Owin.Security.OAuth.OAuthAuthorizationServerHandler.d__0.MoveNext()</p>
  
  <p>--- End of stack trace from previous location where exception was thrown ---</p>
  
  <p>at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)</p>
  
  <p>at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)</p>
  
  <p>at Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1.d__0.MoveNext()</p>
  
  <p>--- End of stack trace from previous location where exception was thrown ---</p>
  
  <p>at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)</p>
  
  <p>at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)</p>
  
  <p>at Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1.d__0.MoveNext()</p>
  
  <p>--- End of stack trace from previous location where exception was thrown ---</p>
  
  <p>at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)</p>
  
  <p>at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)</p>
  
  <p>at Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1.d__0.MoveNext()</p>
  
  <p>--- End of stack trace from previous location where exception was thrown ---</p>
  
  <p>at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)</p>
  
  <p>at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)</p>
  
  <p>at Microsoft.AspNet.Identity.Owin.IdentityFactoryMiddleware`2.d__0.MoveNext()</p>
  
  <p>--- End of stack trace from previous location where exception was thrown ---</p>
  
  <p>at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)</p>
  
  <p>at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)</p>
  
  <p>at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage.d__5.MoveNext()</p>
  
  <p>--- End of stack trace from previous location where exception was thrown ---</p>
  
  <p>at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)</p>
  
  <p>at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)</p>
  
  <p>at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.d__2.MoveNext()</p>
  
  <p>--- End of stack trace from previous location where exception was thrown ---</p>
  
  <p>at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End(IAsyncResult ar)</p>
  
  <p>at Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork(IAsyncResult ar)</p>
  
  <p>at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()</p>
  
  <p>at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)</p>
  
  <p>at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously)</p>
  
  <p>ClientConnectionId:00000000-0000-0000-0000-000000000000</p>
  
  <p>Error Number:258,State:0,Class:20</p>
  
  <p>added the image of the log which i got from azure </p>