Share via

ERROR: SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it.

Nischay 125 Reputation points
2026-03-27T01:32:26.2666667+00:00

Hello,

We have a dashboard running on Azure App Service, connected to an Azure MySQL database. Earlier today, we experienced a connection issue that was resolved after restarting the server. Below are the relevant PHP (Laravel) logs:

2026-03-26 22:27:26] production.ERROR: SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it. {"exception":"[object] (PDOException(code: 2002): SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it. at C:\\home\\site\\wwwroot\\vendor\\laravel\\framework\\src\\Illuminate\\Database\\Connectors\\Connector.php:70) [stacktrace] [2026-03-26 22:27:29] production.ERROR: SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it. (SQL: select * from `classes` where `join_code` = ios_first_run) {"exception":"[object] (Illuminate\\Database\\QueryException(code: 2002):

We also observed a CPU spike on the SQL database around the same time (screenshot attached).

image

Any suggestions or advise on what might have caused this issue, and any steps we can take to prevent it in the future?

Azure Database for MySQL

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.