I have a Docker image with Strapi and a Docker image with Postgres serving a nextjs application in the frontend in a Docker swarm configuration. When the connection ist not used for a while (I would need to measure the time), the first connection attempts fails, but waiting for a few seconds it then works.
Strapi log:
2024-08-17T10:04:34.806228666Z [2024-08-17 10:04:34.805] error: select "t0"."id", "t0"."name", "t0"."description", "t0"."last_used_at", "t0"."type", "t0"."lifespan", "t0"."expires_at", "t0"."created_at", "t0"."updated_at" from "public"."strapi_api_tokens" as "t0" where ("t0"."access_key" = $1) limit $2 - Connection terminated unexpectedly
2024-08-17T10:04:34.806319126Z Error: select "t0"."id", "t0"."name", "t0"."description", "t0"."last_used_at", "t0"."type", "t0"."lifespan", "t0"."expires_at", "t0"."created_at", "t0"."updated_at" from "public"."strapi_api_tokens" as "t0" where ("t0"."access_key" = $1) limit $2 - Connection terminated unexpectedly
2024-08-17T10:04:34.806336784Z at Connection.<anonymous> (/opt/node_modules/pg/lib/client.js:132:73)
2024-08-17T10:04:34.806341883Z at Object.onceWrapper (node:events:632:28)
2024-08-17T10:04:34.806346406Z at Connection.emit (node:events:518:28)
2024-08-17T10:04:34.806350531Z at Connection.emit (node:domain:488:12)
2024-08-17T10:04:34.806354663Z at Socket.<anonymous> (/opt/node_modules/pg/lib/connection.js:57:12)
2024-08-17T10:04:34.806359010Z at Socket.emit (node:events:518:28)
2024-08-17T10:04:34.806363131Z at Socket.emit (node:domain:488:12)
2024-08-17T10:04:34.806367276Z at TCP.<anonymous> (node:net:337:12)
2024-08-17T10:04:34.806371749Z at TCP.callbackTrampoline (node:internal/async_hooks:130:17)
2024-08-17T10:04:34.806527308Z [2024-08-17 10:04:34.806] http: GET /api/homepage?populate=*&locale=en (14 ms) 500
2024-08-17T10:04:40.851039035Z Connection Error: Connection ended unexpectedly
2024-08-17T10:04:40.975209504Z [2024-08-17 10:04:40.968] http: GET /api/service-accordion-items?populate=*&locale=en (125 ms) 200
Postgres log:
2024-08-17T06:14:18.804316063Z 2024-08-17 06:14:18.803 UTC [27] LOG: checkpoint starting: time
2024-08-17T06:14:19.118350310Z 2024-08-17 06:14:19.118 UTC [27] LOG: checkpoint complete: wrote 4 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.307 s, sync=0.003 s, total=0.315 s; sync files=4, longest=0.002 s, average=0.001 s; distance=17 kB, estimate=24 kB; lsn=0/25AF190, redo lsn=0/25AF158
2024-08-17T08:14:23.448351703Z 2024-08-17 08:14:23.440 UTC [23651] LOG: could not receive data from client: Connection reset by peer
2024-08-17T08:25:18.801688216Z 2024-08-17 08:25:18.800 UTC [23650] LOG: could not receive data from client: Connection reset by peer