Symptoms
- Error messages like “connection timeout,” “failed to connect,” or “network error”
- Long delays before errors appear
TimeoutExceptionorNetworkExceptionfrom the HTTP client- Requests that work locally but fail in production (or vice versa)
Verify the API URL and Endpoint
The most common connection problem is an incorrectapiUrl or endpoint in your preset. Double-check both values against the provider’s documentation:
apiUrl, missing the version prefix (e.g. /v1), or using an endpoint path that does not match the driver.
Check Outbound Network Access
Verify that your application environment can reach the provider’s API:curl command fails, the problem is at the network layer, not in Polyglot.
Configure Timeouts
Polyglot uses theHttpClientConfig to control connection and request timeouts. The defaults are 3 seconds for connection and 30 seconds for the request. For slow networks or large requests, increase these values:
Proxy Configuration
If your application runs behind an HTTP proxy, configure the proxy at the HTTP client level. Polyglot itself does not handle proxy settings — it delegates all transport concerns to the HTTP client. The approach depends on your HTTP client driver. For the default cURL driver, you can set proxy options through the system environment:Firewall and Security Groups
In cloud environments, ensure that your security groups or network ACLs allow outbound HTTPS (port 443) to the provider’s domain. Common provider domains to allow:api.openai.comapi.anthropic.comapi.mistral.aigenerativelanguage.googleapis.com(Gemini)localhost:11434(Ollama, local only)
DNS Resolution
If DNS is not resolving the provider’s domain, you will see connection failures even though the network path is clear. Test DNS resolution independently:/etc/resolv.conf).
Local Providers (Ollama)
For local providers like Ollama, confirm that the service is running and listening on the expected address:apiUrl in your preset:
Retry Transient Failures
Network issues are often transient. UseInferenceRetryPolicy to automatically retry on connection failures:
TimeoutException and NetworkException by default.