title: Unable to connect to SQL Server database from IIS hosted application using SQL authentication
body: <p>I have been developing an application in VS 2012 using Entity Framework 6.0 for my backend connectivity. I set up a connection to my SQL Server 2008 database and successfully configured the Entity Framework model (database first) without issue. However, when I attempted to connect to the database when the application is running in IIS, I am consistently getting an exception.</p>
  
  <p>There are several layers of exceptions, but the innermost exception appears as:</p>
  
  <blockquote>
    <p>A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond</p>
  </blockquote>
  
  <p>I have tried extending the connection timeout to 60, but this did not have an impact, nor does it take nearly as long when connecting through other means, so I do not believe it is related to timing out. The calling application is a Web API project and hosted in local IIS and I have copied the exact connection string from my EF model project to the web.config file in this project, which looks like the following:</p>
  
  <pre><code>&lt;add name="ConnectionName" 
       connectionString="metadata=res://*/ModelName.csdl|res://*/ModelName.ssdl|res://*/ModelName.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;data source=server,portnumber;initial catalog=dbname;persist security info=True;user id=user;password=password;MultipleActiveResultSets=True;&amp;quot;" 
       providerName="System.Data.EntityClient" /&gt;
  </code></pre>
  
  <p>I have successfully connected to this connection using a standard SQL Client connection (not from IIS app), through SQL Server Management Studio, and even using the same EF connection string when testing locally, but for some reason I cannot do so while connecting through the code when the app is hosted in IIS. I can confirm that the <code>DbContext</code> class is using the appropriate connection information while debugging.</p>
  
  <p>Update:
  I've discovered that the issue is NOT specific to Entity Framework. The issue is occurring when I test with a SQL client as well. However, it does occur with every application hosted in IIS and not just my Web API application. Still not able to figure exactly what the issue is, however.</p>