Rabia Koç
07/25/2025, 11:22 AMkapa.ai
07/25/2025, 11:22 AMorg.postgresql.util.PSQLException: This connection has been closed. and java.lang.RuntimeException: org.postgresql.util.PSQLException: An I/O error occurred while sending to the backend. indicates that the Airbyte Postgres source connector is losing its connection to the Postgres database during the discovery or read process. This is a common class of error in Airbyte when the underlying JDBC connection is closed unexpectedly. Possible causes and references from knowledge sources: 1. Idle Timeout or Connection Closure by Server: If the Postgres server is configured with an idle-in-transaction timeout or aggressively closes idle connections, you may see similar errors. For example, a related issue is described where the connection is terminated due to idle-in-transaction timeout, resulting in a similar stack trace and error message. The solution in that case is to review and potentially increase the idle_in_transaction_session_timeout setting on your Postgres server, or ensure that Airbyte is not leaving transactions open for too long during discovery or sync operations [[Source Postgres: fails with idle-transaction-timeout issue](https://github.com/airbytehq/airbyte/issues/27715)]. 2. Network Instability or Firewall: Network interruptions, firewalls, or proxies that close idle connections can also cause this. If you are running Airbyte and Postgres in different networks or containers, ensure there are no network policies or firewalls closing the connection unexpectedly. 3. Resource Exhaustion or Connection Pooling Issues: If the Airbyte instance or the Postgres server is under heavy load, or if there are not enough available connections in the pool, you may see connection closure errors. This is also seen in other Airbyte issues where HikariCP (the connection pool) cannot provide a connection in time, leading to timeouts and closed connections [[Any database connection times out](https://github.com/airbytehq/airbyte/issues/32129)]. 4. Postgres JDBC Driver or Connector Bugs: In rare cases, bugs in the JDBC driver or the Airbyte connector itself can cause connections to be closed unexpectedly. Upgrading to the latest compatible versions of Airbyte and the connectors may help. What you can do: - Check the Postgres server logs for any indication of why the connection was closed. - Review and adjust the idle_in_transaction_session_timeout and related timeout settings on your Postgres server. - Ensure network stability between Airbyte and Postgres. - Monitor resource usage on both Airbyte and Postgres. - If you are using SSH tunnels, ensure the tunnel remains open and stable during the sync. - Try restarting Airbyte and Postgres to clear any stale connections. If the problem persists after these checks, please provide more details about your environment (e.g., are you using SSH, what are your Postgres timeout settings, is there a proxy/firewall between Airbyte and Postgres, etc.) for more targeted troubleshooting. Let me know if you need help interpreting specific log lines or configuration settings!