Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

General error: 20003 Adaptive Server connection timed out [20003] (severity 6)

Hi Following is error what I am getting:-

PDOException: SQLSTATE[HY000]: General error: 20003 Adaptive Server connection timed out [20003] (severity
 6) [(null)] in /var/www/html/web/vendor/laravel/framework/src/Illuminate/Database/Connection.php:335

I am trying to connect to MS-SQL-Server on windows from linux laravel 5.2 code snippet.

  1. There is firewall disable on windows machine.
  2. I am able to telnet on windows ip on ms sql default available port.
  3. I am not using free TDS, so this is not duplicate of TDS and even that question is not answered.
  4. centos 7, able to ping to IP. there is no connection issue.
  5. Running script from terminal, so no timeout issue must be come.

Before I was trying to fetch 5k records, I thot query is taking longer time but even I reduce a limit to 100 then also getting same error. My net connection is high speed and server hardware is highly configured.

I have tried all the solution given on below link and I am getting success but when my script runs facing above issue.

[https://blogs.msdn.microsoft.com/sql_protocols/2008/04/30/steps-to-troubleshoot-sql-connectivity-issues/][1]

My script run well locally. But facing issue when I promoted code to dev.

like image 851
vishal-mote Avatar asked Dec 23 '16 12:12

vishal-mote


People also ask

Is a dead connection reported as a timeout in Azure SQL?

I've dug into this a little today, I don't believe its any problem with Azure SQL, but for some reason, a dead connection from any SQL Server is reported as a timeout. You need to actually check DEADPROC in the err_handler and then return INT_EXIT instead

What are the causes of connection timed out?

There can be various causes that can turn out to be the potential reasons for the connection timed out error. Some of these causes are mentioned below: Slow Internet Connection: Slow Internet connection is one of the possible reasons for the error.

What is err_connection_timed_out error?

What Is Err_Connection_Timed_Out Error The connection timed out error isn’t a harmful error or any infected file that can cause harm to your system. This message is mainly the notification that the system is unable to set up a connection with the server.

How does FreeTDS/tiny TDs handle the 20003 error?

Then FreeTDS/Tiny TDS go in a loop with the server, responding with INT_CONTINUE. The server responds again with the 20003 error. They back and forth until the unicorn master is fed up and reaps the process.


1 Answers

The problem seems to be related to the execution time for your query.

I was having this same issue and it was solved after I've changed the timeout settings at config/databases.php file.

Use the code below:

'options' => [
    PDO::ATTR_TIMEOUT => 300, // up to 5 minutes
],

The complete config should be:

'sqlsrv' => [
    'driver' => 'sqlsrv',
    'host' => env('DB_HOST', 'localhost'),
    'port' => env('DB_PORT', '3306'),
    'database' => env('DB_DATABASE', 'forge'),
    'username' => env('DB_USERNAME', 'forge'),
    'password' => env('DB_PASSWORD', ''),
    'prefix' => '',
    'options' => [
        PDO::ATTR_TIMEOUT => 300,
    ],
],
like image 183
lucasvscn Avatar answered Oct 31 '22 11:10

lucasvscn