Applies to:
- Liquibase Pro
- Liquibase Open Source (Community)
Conditions:
- Any version of Liquibase Pro or Open Source
- Any supported database
Issue Summary:
Liquibase connects to the database using either a JDBC driver or a native executor. The network handshake occurs between the driver or native executor and the database.
When attempting to establish a connection between the driver and the database, a connection error can occur that will prevent Liquibase from being able to send changesets to the database to execute.
Error Message:
The error message will change slightly based on the target database, but the general error will reference either a connection timeout or connection refusal.
Example Error Messages:
Caused by: java.net.SocketTimeoutException: connect timed out
Connection could not be created to jdbc:://:/ with driver ''. Last message was ' Timed out after 60 seconds while attempting connection 1 of 1'
Potential Root Causes:
Connection Timeout
A connection timeout occurs when a network request is made, but the client does not receive a response within the specified time period.
This can be caused by:
- Network Congestion: Heavy network traffic can delay responses.
- Server Load: The server may be too busy to respond.
- Firewalls/Security: Firewalls or security software may be blocking the request or slowing it down.
- Network Configuration Issues: Problems with routing or DNS resolution.
- Server Down: The server may be down or not responding.
Connection Refused
A connection refused error occurs when the client makes a request to a server, but the server rejects the connection attempt.
This can be caused by:
- Server Not Listening: The server is not listening on the specified port.
- Firewall/Security: Firewalls or security software explicitly block the connection.
- Service Down: The service you are trying to connect to is not running on the server.
- Incorrect Port/Address: The client is trying to connect to the wrong port or IP address.
- Misconfigured Server: The server configuration does not allow connections from the client.
Troubleshooting:
Since a connection issue can be caused by multiple things, there isn't a single troubleshooting step that is guaranteed to resolve the issue, so below is a list of items to check to narrow down what might be causing your connection issue:
-
Database/server
- Ensure that the database is running and accepting connections.
- Ensure that the database name and host are all configured correctly.
-
Connection outside of Liquibase
- Can another tool/application connect to the database using either JDBC or a native executor? This can help isolate whether there is an issue with the server or computer's ability to connect to the database.
-
Network logs
- Viewing the network logs when Liquibase attempts to connect to the database will show if the connection attempt is making it from the driver to the database.
Increasing Connection Timeout Duration
If the connection issue is due to the connection timeout duration being too low, the JDBC driver can be passed a new timeout duration.
This attribute needs to be passed to the driver via the JDBC URL as it is a driver configuration setting.
Oracle example:
jdbc:oracle:thin:@:/?oracle.net.CONNECT_TIMEOUT=5000
Each database driver has its own version of how to set the connection timeout. Consult the respective driver's documentation to find the correct value to use.
Comments
0 comments
Article is closed for comments.