What's the port for the database?

I’m trying to connect to my database, what’s the port? this is my current DB config:

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=id8706490_agenda
DB_USERNAME=id8706490_user
DB_PASSWORD=[password]

I get the following error: SQLSTATE[HY000] [2002]

The port is 3306, as you already have. :slight_smile:

please check my update, I’ve added the error code

Do you have a screenshot to share? :slight_smile:

what do you want to see in the screenshot? I honestly never had this much trouble connection my database to my Lumen/Laravel projects

I need a screenshot to see what the exact issue is. :slight_smile:

yeah, but what do you want to see in the screenshot? the error is exactly what I said, SQLSTATE[HY000] [2002] (aka connection refused). no extra data is given, only a callstack in `my log without any further data/variable values provided

Can you please screenshot what you’re seeing so I can also see the page URL?

this is the image, I’ll post the callstack below:

Message truncated

[2019-02-18 17:40:51] production.ERROR: PDOException: SQLSTATE[HY000] [2002] Connection refused in /storage/ssd4/490/8706490/vendor/illuminate/database/Connectors/Connector.php:70
Stack trace:
#0 /storage/ssd4/490/8706490/vendor/illuminate/database/Connectors/Connector.php(70): PDO->__construct(‘mysql:host=127…’, ‘forge’, ‘’, Array)
#1 /storage/ssd4/490/8706490/vendor/illuminate/database/Connectors/Connector.php(46): Illuminate\Database\Connectors\Connector->createPdoConnection(‘mysql:host=127…’, ‘forge’, ‘’, Array)
#2 /storage/ssd4/490/8706490/vendor/illuminate/database/Connectors/MySqlConnector.php(24): Illuminate\Database\Connectors\Connector->createConnection(‘mysql:host=127…’, Array, Array)
#3 /storage/ssd4/490/8706490/vendor/illuminate/database/Connectors/ConnectionFactory.php(182): Illuminate\Database\Connectors\MySqlConnector->connect(Array)
#4 [internal function]: Illuminate\Database\Connectors\ConnectionFactory->Illuminate\Database\Connectors{closure}()
#5 /storage/ssd4/490/8706490/vendor/illuminate/database/Connection.php(918): call_user_func(Object(Closure))
#6 /storage/ssd4/490/8706490/vendor/illuminate/database/Connection.php(943): Illuminate\Database\Connection->getPdo()
#7 /storage/ssd4/490/8706490/vendor/illuminate/database/Connection.php(399): Illuminate\Database\Connection->getReadPdo()
#8 /storage/ssd4/490/8706490/vendor/illuminate/database/Connection.php(325): Illuminate\Database\Connection->getPdoForSelect(true)
#9 /storage/ssd4/490/8706490/vendor/illuminate/database/Connection.php(657): Illuminate\Database\Connection->Illuminate\Database{closure}(‘select * from ...', Array) #10 /storage/ssd4/490/8706490/vendor/illuminate/database/Connection.php(624): Illuminate\Database\Connection->runQueryCallback('select * from…’, Array, Object(Closure))
#11 /storage/ssd4/490/8706490/vendor/illuminate/database/Connection.php(333): Illuminate\Database\Connection->run(‘select * from ...', Array, Object(Closure)) #12 /storage/ssd4/490/8706490/vendor/illuminate/database/Query/Builder.php(2095): Illuminate\Database\Connection->select('select * from…’, Array, true)
#13 /storage/ssd4/490/8706490/vendor/illuminate/database/Query/Builder.php(2083): Illuminate\Database\Query\Builder->runSelect()
#14 /storage/ssd4/490/8706490/vendor/illuminate/database/Query/Builder.php(2569): Illuminate\Database\Query\Builder->Illuminate\Database\Query{closure}()
#15 /storage/ssd4/490/8706490/vendor/illuminate/database/Query/Builder.php(2084): Illuminate\Database\Query\Builder->onceWithColumns(Array, Object(Closure))
#16 /storage/ssd4/490/8706490/vendor/illuminate/database/Eloquent/Builder.php(516): Illuminate\Database\Query\Builder->get(Array)
#17 /storage/ssd4/490/8706490/vendor/illuminate/database/Eloquent/Builder.php(500): Illuminate\Database\Eloquent\Builder->getModels(Array)
#18 /storage/ssd4/490/8706490/vendor/illuminate/database/Eloquent/Model.php(461): Illuminate\Database\Eloquent\Builder->get(Array)
#19 /storage/ssd4/490/8706490/app/Http/Controllers/AgendaController.php(33): Illuminate\Database\Eloquent\Model::all()
#20 [internal function]: App\Http\Controllers\AgendaController->full(Object(Laravel\Lumen\Http\Request))
#21 /storage/ssd4/490/8706490/vendor/illuminate/container/BoundMethod.php(29): call_user_func_array(Array, Array)
#22 /storage/ssd4/490/8706490/vendor/illuminate/container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container{closure}()
#23 /storage/ssd4/490/8706490/vendor/illuminate/container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Laravel\Lumen\Application), Array, Object(Closure))
#24 /storage/ssd4/490/8706490/vendor/illuminate/container/Container.php(572): Illuminate\Container\BoundMethod::call(Object(Laravel\Lumen\Application), Array, Array, NULL)
#25 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(378): Illuminate\Container\Container->call(Array, Array)
#26 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(344): Laravel\Lumen\Application->callControllerCallable(Array, Array)
#27 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(318): Laravel\Lumen\Application->callLumenController(Object(App\Http\Controllers\AgendaController), ‘full’, Array)
#28 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(280): Laravel\Lumen\Application->callControllerAction(Array)
#29 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(265): Laravel\Lumen\Application->callActionOnArrayBasedRoute(Array)
#30 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(165): Laravel\Lumen\Application->handleFoundRoute(Array)
#31 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(418): Laravel\Lumen\Application->Laravel\Lumen\Concerns{closure}(Object(Laravel\Lumen\Http\Request))
#32 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(171): Laravel\Lumen\Application->sendThroughPipeline(Array, Object(Closure))
#33 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(108): Laravel\Lumen\Application->dispatch(NULL)
#34 /storage/ssd4/490/8706490/public_html/index.php(28): Laravel\Lumen\Application->run()
#35 {main}

Next Illuminate\Database\QueryException: SQLSTATE[HY000] [2002] Connection refused (SQL: select * from group) in /storage/ssd4/490/8706490/vendor/illuminate/database/Connection.php:664
Stack trace:
#0 /storage/ssd4/490/8706490/vendor/illuminate/database/Connection.php(624): Illuminate\Database\Connection->runQueryCallback(‘select * from ...', Array, Object(Closure)) #1 /storage/ssd4/490/8706490/vendor/illuminate/database/Connection.php(333): Illuminate\Database\Connection->run('select * from…’, Array, Object(Closure))
#2 /storage/ssd4/490/8706490/vendor/illuminate/database/Query/Builder.php(2095): Illuminate\Database\Connection->select(‘select * from ...', Array, true) #3 /storage/ssd4/490/8706490/vendor/illuminate/database/Query/Builder.php(2083): Illuminate\Database\Query\Builder->runSelect() #4 /storage/ssd4/490/8706490/vendor/illuminate/database/Query/Builder.php(2569): Illuminate\Database\Query\Builder->Illuminate\Database\Query\{closure}() #5 /storage/ssd4/490/8706490/vendor/illuminate/database/Query/Builder.php(2084): Illuminate\Database\Query\Builder->onceWithColumns(Array, Object(Closure)) #6 /storage/ssd4/490/8706490/vendor/illuminate/database/Eloquent/Builder.php(516): Illuminate\Database\Query\Builder->get(Array) #7 /storage/ssd4/490/8706490/vendor/illuminate/database/Eloquent/Builder.php(500): Illuminate\Database\Eloquent\Builder->getModels(Array) #8 /storage/ssd4/490/8706490/vendor/illuminate/database/Eloquent/Model.php(461): Illuminate\Database\Eloquent\Builder->get(Array) #9 /storage/ssd4/490/8706490/app/Http/Controllers/AgendaController.php(33): Illuminate\Database\Eloquent\Model::all() #10 [internal function]: App\Http\Controllers\AgendaController->full(Object(Laravel\Lumen\Http\Request)) #11 /storage/ssd4/490/8706490/vendor/illuminate/container/BoundMethod.php(29): call_user_func_array(Array, Array) #12 /storage/ssd4/490/8706490/vendor/illuminate/container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}() #13 /storage/ssd4/490/8706490/vendor/illuminate/container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Laravel\Lumen\Application), Array, Object(Closure)) #14 /storage/ssd4/490/8706490/vendor/illuminate/container/Container.php(572): Illuminate\Container\BoundMethod::call(Object(Laravel\Lumen\Application), Array, Array, NULL) #15 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(378): Illuminate\Container\Container->call(Array, Array) #16 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(344): Laravel\Lumen\Application->callControllerCallable(Array, Array) #17 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(318): Laravel\Lumen\Application->callLumenController(Object(App\Http\Controllers\AgendaController), 'full', Array) #18 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(280): Laravel\Lumen\Application->callControllerAction(Array) #19 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(265): Laravel\Lumen\Application->callActionOnArrayBasedRoute(Array) #20 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(165): Laravel\Lumen\Application->handleFoundRoute(Array) #21 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(418): Laravel\Lumen\Application->Laravel\Lumen\Concerns\{closure}(Object(Laravel\Lumen\Http\Request)) #22 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(171): Laravel\Lumen\Application->sendThroughPipeline(Array, Object(Closure)) #23 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(108): Laravel\Lumen\Application->dispatch(NULL) #24 /storage/ssd4/490/8706490/public_html/index.php(28): Laravel\Lumen\Application->run() #25 {main} {"exception":"[object] (Illuminate\\Database\\QueryException(code: 2002): SQLSTATE[HY000] [2002] Connection refused (SQL: select * fromgroup) at /storage/ssd4/490/8706490/vendor/illuminate/database/Connection.php:664, PDOException(code: 2002): SQLSTATE[HY000] [2002] Connection refused at /storage/ssd4/490/8706490/vendor/illuminate/database/Connectors/Connector.php:70) [stacktrace] #0 /storage/ssd4/490/8706490/vendor/illuminate/database/Connection.php(624): Illuminate\\Database\\Connection->runQueryCallback('select * from…’, Array, Object(Closure))
#1 /storage/ssd4/490/8706490/vendor/illuminate/database/Connection.php(333): Illuminate\Database\Connection->run(‘select * from ...', Array, Object(Closure)) #2 /storage/ssd4/490/8706490/vendor/illuminate/database/Query/Builder.php(2095): Illuminate\\Database\\Connection->select('select * from…’, Array, true)
#3 /storage/ssd4/490/8706490/vendor/illuminate/database/Query/Builder.php(2083): Illuminate\Database\Query\Builder->runSelect()
#4 /storage/ssd4/490/8706490/vendor/illuminate/database/Query/Builder.php(2569): Illuminate\Database\Query\Builder->Illuminate\Database\Query\{closure}()
#5 /storage/ssd4/490/8706490/vendor/illuminate/database/Query/Builder.php(2084): Illuminate\Database\Query\Builder->onceWithColumns(Array, Object(Closure))
#6 /storage/ssd4/490/8706490/vendor/illuminate/database/Eloquent/Builder.php(516): Illuminate\Database\Query\Builder->get(Array)
#7 /storage/ssd4/490/8706490/vendor/illuminate/database/Eloquent/Builder.php(500): Illuminate\Database\Eloquent\Builder->getModels(Array)
#8 /storage/ssd4/490/8706490/vendor/illuminate/database/Eloquent/Model.php(461): Illuminate\Database\Eloquent\Builder->get(Array)
#9 /storage/ssd4/490/8706490/app/Http/Controllers/AgendaController.php(33): Illuminate\Database\Eloquent\Model::all()
#10 [internal function]: App\Http\Controllers\AgendaController->full(Object(Laravel\Lumen\Http\Request))
#11 /storage/ssd4/490/8706490/vendor/illuminate/container/BoundMethod.php(29): call_user_func_array(Array, Array)
#12 /storage/ssd4/490/8706490/vendor/illuminate/container/BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#13 /storage/ssd4/490/8706490/vendor/illuminate/container/BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Laravel\Lumen\Application), Array, Object(Closure))
#14 /storage/ssd4/490/8706490/vendor/illuminate/container/Container.php(572): Illuminate\Container\BoundMethod::call(Object(Laravel\Lumen\Application), Array, Array, NULL)
#15 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(378): Illuminate\Container\Container->call(Array, Array)
#16 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(344): Laravel\Lumen\Application->callControllerCallable(Array, Array)
#17 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(318): Laravel\Lumen\Application->callLumenController(Object(App\Http\Controllers\AgendaController), ‘full’, Array)
#18 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(280): Laravel\Lumen\Application->callControllerAction(Array)
#19 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(265): Laravel\Lumen\Application->callActionOnArrayBasedRoute(Array)
#20 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(165): Laravel\Lumen\Application->handleFoundRoute(Array)
#21 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(418): Laravel\Lumen\Application->Laravel\Lumen\Concerns\{closure}(Object(Laravel\Lumen\Http\Request))
#22 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(171): Laravel\Lumen\Application->sendThroughPipeline(Array, Object(Closure))
#23 /storage/ssd4/490/8706490/vendor/laravel/lumen-framework/src/Concerns/RoutesRequests.php(108): Laravel\Lumen\Application->dispatch(NULL)
#24 /storage/ssd4/490/8706490/public_html/index.php(28): Laravel\Lumen\Application->run()
#25 {main}
"}

:star: Are you on a PHP version that is supported by the software?

:star: Have you enabled PHP errors to get a better understanding of the issue?

:star: Have you made any changes to the core software before the issue started?

:star: What happened right before the software broke and started showing the error?

  1. yes, 7.1+ is required, the server is running on 7.1
  2. I’m not getting PHP errors, I’m getting SQL errors, those are being logged, on my local host, Lumen also throws those on the screen with a readable callstack, but for some reason, this is disabled on the live version.
  3. no I haven’t
  4. nothing, this is the first version, it works perfectly on my localhost (work laptop in this case)

If it’s an SQL error, I’m guessing that the script is using too many connections. 000webhost has restrictions in place to prevent abuse of SQL commands, so I’m guessing that’s the case here.

how many is the max request per time period? I can’t imagine it’s less then 100 per minute, I’m currently accessing the database no more then 5 times per refresh of the page.

I also tried with just one request earlier, same result

I’m clearly not hitting those limits anywhere near

Please create a separate file and put the following code into it

<?php
$servername = "localhost";
$username = "username";
$password = "password";

// Create connection
$conn = new mysqli($servername, $username, $password);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
echo "Connected successfully";
?>

Be sure to replace the credentials with the correct ones.
And do tell us the results.

2 Likes