I have few microservices that uses one database, laravel and java,everything is served by docker.
Yesterday everything was fine, but today without any change in code or system nothing can use database.
I can connect do database in DBeaver and everything is how it should.
Every microservice failing to timeout expired, I trying to fix it for almost 4 hours and don't have any idea left what can be wrong.
Anyone had this problem or know how to fix it?
Errors:
Laravel app connect's to db (tried to change data like host or port and then error was instant without any timeouts), but after first attempt to use it doesn't get response.
In db logs nothing, only that ones from dbeaver.
Illuminate\Database\QueryException
SQLSTATE[08006] [7] timeout expired (SQL: insert into "oauth_clients" ("user_id", "name", "secret", "provider", "redirect", "personal_access_client", "password_client", "revoked", "updated_at", "created_at") values (?, Docker_Laravel Personal Access Client, cfwun6QVegsGWm7rqRdguVuPUs5YcXFLtq1VubZY, ?, http://localhost, 1, 0, 0, 2021-08-27 09:55:14, 2021-08-27 09:55:14) returning "id")
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:671
667| // If an exception occurs when attempting to run a query, we'll format the error
668| // message to include the bindings with SQL, which will make this exception a
669| // lot more helpful to the developer instead of just the database's errors.
670| catch (Exception $e) {
> 671| throw new QueryException(
672| $query, $this->prepareBindings($bindings), $e
673| );
674| }
675|
database throws no error, and connection setting are correct, nothing was changed everything is on same HEAD which worked before.
Edit
I also should mention that laravel connect's with db through docker and when I changed host and port to the same as in dbeaver(which worked) laravel api didn't connect at all.
Docker Compose:
version: '3'
services:
db:
container_name: name_db
build:
context: ./docker
dockerfile: db_dockerfile
restart: always
ports:
- 5431:5432
environment:
POSTGRES_USER: ---
POSTGRES_PASSWORD: ---
logging:
options:
max-size: 50m
command: ["postgres", "-c", "log_statement=all"]
user_api:
container_name: name_api
restart: always
build:
context: ./docker/user_api
ports:
- "${API_PORT}:80"
volumes:
- ./user_api:/var/www/app
My Answer:
you please provide more context or clarify your question?
Rate this post
5 of 5 based on 9722 votesComments