Blog Post

Azure Database Support Blog
6 MIN READ

Azure PostgreSQL Lesson Learned #15: Troubleshooting JDBC SSL Timeouts and DNS Latency

linbe's avatar
linbe
Icon for Microsoft rankMicrosoft
Nov 18, 2026

Case Overview:

A customer experienced intermittent connection failures between a Java application and Azure Database for PostgreSQL Flexible Server. The failures occurred while establishing new database connections, when the PostgreSQL JDBC driver was waiting for the server’s SSL negotiation response.

The investigation reviewed PostgreSQL server logs, Java application logs, and network packet traces. These showed that some connections were closed before SSL negotiation completed. No database resource constraints were identified during the affected periods.

The server parameter log_hostname was enabled. This setting introduces hostname resolution into connection handling and can increase connection-establishment latency when reverse DNS lookups are slow. The issue was mitigated after the customer disabled this parameter across the Dev, SIT, UAT, and PROD environments.

Symptoms: How the Problem Appears

  • PostgreSQL server logs

The PostgreSQL server recorded the following message during affected periods:

could not accept SSL connection: EOF detected

The log entry contained these details:

Field

Value

Message

could not accept SSL connection: EOF detected

Error level

LOG

SQL error code

08P01

This message indicates that the connection ended before the server completed the SSL handshake. It does not, by itself, establish why the connection was closed.

  • Java application logs

The Java application recorded socket read timeouts while the PostgreSQL JDBC driver was waiting for the SSL negotiation response. Relevant stack trace entries included:

-----------------

Caused by: java.net.SocketTimeoutException: Read timed out

  at java.base/sun.nio.ch.NioSocketImpl.timedRead(NioSocketImpl.java:288)

  at java.base/sun.nio.ch.NioSocketImpl.implRead(NioSocketImpl.java:314)

  at java.base/sun.nio.ch.NioSocketImpl.read(NioSocketImpl.java:355)

  at java.base/sun.nio.ch.NioSocketImpl$1.read(NioSocketImpl.java:808)

  at java.base/java.net.Socket$SocketInputStream.read(Socket.java:966)

  at org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:192)

  at org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:159)

  at org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:144)

  at org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:76)

  at org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:76)

  at org.postgresql.core.PGStream.receiveChar(PGStream.java:476)

  at org.postgresql.core.v3.ConnectionFactoryImpl.enableSSL(ConnectionFactoryImpl.java:600)

  at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:201)

-----------------

These entries show that the driver reached its read timeout while waiting for the server’s response during SSL negotiation.

  • Other observations
    • Network packet traces: The client sent an SSL request to the database, but the server didn't respond for about 5 seconds. The client then closed the connection (FIN), and the server's reply arrived after that. This 5-second wait matches the JDBC driver's default sslResponseTimeout, which is why the client disconnected.
    • No database resource performance constraints were identified.
    • The application was reported to be using the default PostgreSQL JDBC connection settings.

Root Cause:

The investigation identified the enabled log_hostname parameter as a contributing factor to connection-establishment latency.

When log_hostname is enabled, PostgreSQL resolves connecting clients’ IP addresses to hostnames for logging. Slow or inconsistent reverse DNS resolution can therefore delay connection processing.

The evidence was consistent with the following sequence:

  1. The application initiated a new database connection and requested SSL.
  2. Connection processing was delayed, with hostname resolution identified as a contributing factor.
  3. The JDBC driver’s timeout expired while it waited for the SSL negotiation response.
  4. The client closed the connection.
  5. PostgreSQL subsequently encountered the closed connection during SSL processing and logged could not accept SSL connection: EOF detected.

The mitigation outcome supported the finding that hostname resolution was contributing to the failures. However, the EOF message alone should not be treated as proof of a DNS issue.

 

Step‑By‑Step Troubleshooting Guidance:

   1. Correlate server and application errors

Identify the affected time window and compare:

    • PostgreSQL SSL-related log entries.
    • Java application connection errors and stack traces.
    • Network packet traces, where available.

Align timestamps and time zones to confirm that the errors correspond to the same connection attempts.

    2. Identify the connection stage that is timing out

Review the application stack trace to determine whether the failure occurs during TCP connection establishment, SSL negotiation, authentication, or query execution.

In this case, the evidence showed the following correlation:

    New connection → SSL negotiation → connection-processing delay → JDBC timeout → client closes connection → PostgreSQL logs EOF detected

The Java application was using the default PostgreSQL JDBC connection settings. During the issue,  the application reached it's timeout while waiting for the SSL response and eventually terminated the connections.

PostgreSQL subsequently detected that the client-side connection had disappeared while the server was handling SSL negotiation, resulting with the error "could not accept SSL connection: EOF detected".

    3. Check database resource utilization

Review database CPU, memory, storage latency, and connection counts during the affected period.

This helps determine whether resource pressure or connection saturation could explain the delay. No such constraints were identified in this investigation.

    4. Review hostname logging and DNS performance

Check the log_hostname setting under Server parameters for the Azure Database for PostgreSQL Flexible Server instance.

If it is enabled:

    • Confirm whether resolved client hostnames are operationally required.
    • Investigate reverse DNS lookup latency for the client IP addresses.
    • Where possible, evaluate DNS behavior from the server’s resolution path; a lookup from an unrelated machine may not reproduce the same conditions.

    5. Disable unnecessary hostname logging

If hostname logging is not required, set:

log_hostname = off

Save the change, establish new application connections, and monitor whether connection failures decrease.

Disabling this parameter removes hostname resolution performed specifically for hostname logging. It does not disable SSL or eliminate other DNS dependencies.

Disabling log_hostname does not require a server restart. The change takes effect when the configuration is reloaded, and it applies to all new connections from then on.

    6. Review JDBC timeout settings

    • As an additional resiliency measure, consider increasing sslResponseTimeout when justified by expected connection latency.

The documented default is 5,000 milliseconds. For example, increasing it to 10,000 milliseconds allows more time for the initial SSL negotiation response:

   sslResponseTimeout=10000

Add this property to the existing JDBC connection configuration without weakening its SSL certificate-validation settings.

    • Review connectTimeout In pgJDBC driver: a connectTimeout shorter than sslResponseTimeout limits the SSL response wait. The units differ: sslResponseTimeout is in milliseconds and connectTimeout is in seconds. The default connectTimeout is 10 seconds, so an sslResponseTimeout above 10,000 ms has no effect unless connectTimeout is raised too.

    • Also check that the connection-pool timeout (for example, HikariCP connectionTimeout) is long enough to allow for the SSL response wait.

    • Increasing the timeout is a resiliency measure, not a substitute for addressing the underlying delay. 

    7. Validate the mitigation

After applying the change, monitor:

    • New-connection success rates and establishment times.
    • Java socket timeout errors.
    • PostgreSQL SSL EOF messages.
    • Connection behavior under representative application load.

Validate each environment separately before considering the mitigation complete.

 

Final Outcome:

The connection issue was reported in all four environments: Dev, SIT, UAT and PROD. All four use the same custom DNS server. When log_hostname is enabled, the server does a reverse DNS lookup for every new connection.

The customer disabled log_hostname on the Dev, SIT, UAT and PROD servers. This reduced the number of lookups sent to the shared DNS server, and the connection failures stopped soon after the change. This indicates that the root cause was load on the shared DNS server from hostname resolution.

Increasing sslResponseTimeout is still an optional resiliency measure on the application side. It is not the primary mitigation.

 

Best Practices:

  1. Keep log_hostname disabled unless hostname logging is specifically required

For production environments, avoid enabling log_hostname unless there is a clear operational requirement for PostgreSQL logs to contain resolved client hostnames.

Enabling hostname logging introduces additional DNS resolution work when handling connections and can impose a non-negligible performance penalty.

Where possible, retain client IP addresses in PostgreSQL logs and perform hostname correlation through external monitoring or DNS tooling when required.

 

  1. Validate DNS performance before enabling log_hostname

If hostname logging is required, verify that reverse DNS resolution for application client IP addresses is reliable and consistently responds with low latency.

Slow or inconsistent reverse DNS resolution can introduce additional connection-establishment latency.

 

  1. Configure appropriate JDBC connection timeouts

Applications should use timeout values that reflect the expected network conditions and application resiliency requirements.

Where short transient delays are possible, an appropriate sslResponseTimeout can prevent connections from being terminated prematurely.

 

  1. Monitor SSL handshake failures

Monitor PostgreSQL logs for recurring messages such as: "could not accept SSL connection: EOF detected".

A small number of these messages can occur when clients disconnect during SSL negotiation. A sustained or sudden increase should be correlated with application errors, network telemetry, DNS performance, database server performance and connection rates.

 

Helpful References:

Updated Nov 18, 2026
Version 1.0
No CommentsBe the first to comment