Skip to content

PostgreSQL connections are not released after QR/reconnect failures #112

Description

@netoduwe

Welcome!

  • Yes, I have searched for similar issues on GitHub and found none.

What did you do?

I am running Evolution GO in Docker with PostgreSQL 15 on Linux.

Environment summary:

  • evolution-go: 0.7.2
  • Docker image: evoapicloud/evolution-go:0.7.2
  • PostgreSQL 15
  • standalone Docker Compose deployment

I have 2 WhatsApp instances.

After QR generation / reconnect attempts, the application started failing to reconnect properly. During investigation, I checked PostgreSQL activity and noticed a large number of idle connections coming from the Evolution GO container, especially against the auth database.

At one point, PostgreSQL reached the connection limit and Evolution GO started failing on QR and send flows.

Restarting only the evolution-go container released those connections and the QR flow started working again.

This looks like database connections may not be properly released after failed initialization or reconnect attempts.

What did you expect?

I expected Evolution GO to reuse or release PostgreSQL connections correctly during QR generation, reconnect attempts, and failed session initialization.

Even if an instance fails to reconnect, the application should not keep accumulating idle database connections until PostgreSQL reaches max_connections.

What did you observe instead of what you expected?

Instead, PostgreSQL connections kept accumulating as idle connections from the Evolution GO container.

After enough reconnect / QR attempts, PostgreSQL started returning connection limit errors and Evolution GO stopped working correctly.

Observed effects:

  • QR code endpoint failed
  • send flows failed
  • instance/session state became inconsistent
  • application logs later showed "no active session found"

The issue was temporarily resolved by restarting only the evolution-go container, which immediately reduced the number of open PostgreSQL connections.

Screenshots/Videos

I can provide:

  • screenshots of the disconnected instance state
  • QR refresh failure
  • logs showing "no active session found"
  • PostgreSQL connection counts before and after restarting the container

Which version are you using?

0.7.2
Docker image: evoapicloud/evolution-go:0.7.2
PostgreSQL 15

What is your environment?

Linux

If applicable, paste the log output

Initial related error:
failed to upgrade database: failed to check if version table is up to date: pq: sorry, too many clients already

Later application error:
Erro ao enviar texto: Error: no active session found
at request (.../functions/_shared/evolution-client.ts:404:13)
at async Server. (.../functions/evolution-send-text/index.ts:50:20)

Database observation:

  • max_connections: 100
  • idle connections reached: 99 for the auth database
  • after restarting only the evolution-go container, connections dropped back to normal

Additional Notes

This report is based on repeated behavior in production.

I cannot fully confirm yet whether this is an upstream bug or an environment-specific issue, but the behavior strongly suggests a connection leak or missing connection cleanup during failed QR/reconnect/session initialization flows.

Also, I noticed that one status endpoint appeared stale while another status endpoint reflected the live state correctly. If needed, I can open a separate issue specifically for the status inconsistency, since it may be unrelated to the PostgreSQL connection accumulation problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions