title: Suddenly getting "Login timeout expired" error when connecting to SQL Server
body: <p>Other people have asked this question, but I didn't find an answer that specifically addresses the problem I was getting nor that solved the issue. So I'm posting the question and answer.</p>
  
  <p>A few days ago I had a couple automated scripts that connect to SQL Server and export some data, suddenly stop working. They've been running fine for like 7 years, so that this was odd. Both scripts use different methods to connect. One uses a Perl library, the other uses the <code>bcp</code> command. But both were getting the same error. I'll just show the <code>bcp</code> command for brevity. This is all running on Windows Server 2008, with SQL Server 2008 R2, v10.50. This is what I was running:</p>
  
  <pre><code>"C:\Program Files\Microsoft SQL Server\100\Tools\Binn\bcp.exe" "&lt;my query&gt;" queryout "&lt;output file name&gt;" -T -S MYSERVER -c -k
  </code></pre>
  
  <p>This is the error I was getting:</p>
  
  <blockquote>
    <p>SQLState = 08001, NativeError = 10061<br>
    Error = [Microsoft][SQL Server Native Client 10.0]TCP Provider: No connection could be made because the target machine actively refused it.</p>
    
    <p>SQLState = 08001, NativeError = 10061<br>
    Error = [Microsoft][SQL Server Native Client 10.0]A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online.</p>
    
    <p>SQLState = S1T00, NativeError = 0<br>
    Error = [Microsoft][SQL Server Native Client 10.0]Login timeout expired</p>
  </blockquote>