Dartl's avatar
Level 1

Periodic errors SQLSTATE[HY000] [2002] No such file or directory

I encountered a problem, the server is on Ubuntu. Laravel 10 is installed.

The site is mainly a point for the API. The database is configured correctly, everything works, but sometimes I get an error:

SQLSTATE[HY000] [2002] No such file or directory (Connection: mysql, SQL: select * from personal_access_tokens where personal_access_tokens.id = 401206 limit 1)

I will clarify, the connection to the database is configured and basically works, except for periodic errors like this. The error occurs in different places, in this case in the Middleware where I check if the user is blocked before giving access to the API.

An independent search for a solution did not yield any results, mainly in the threads they discuss that the connection to the database is configured incorrectly, but I think in this case the whole site would not work.

My .env:

DB_CONNECTION=mysql

DB_HOST=127.0.0.1

DB_PORT=3306

DB_DATABASE=db

DB_USERNAME=db_user

DB_PASSWORD=password

DB_SOCKET=/run/mysqld/mysqld.sock

It seems, in my inexperienced opinion, that the script periodically does not get access to the .sock file, but I do not know how to solve this.

0 likes
0 replies

Please or to participate in this conversation.