My function cannot connect to Private Network resources at startup
Problem
When my Serverless Function instance starts, I get errors such as:
- "No route to host" error message
- "Connection timeout" error message
- Other connection failures when trying to reach resources in the same Private Network (PN) (such as databases, Instances, etc.)
Cause
The Serverless Function instance starts on a node where the PN is not yet fully available.
Solutions
Since a September 2026 update, the function instance waits for the PN router (169.254.169.254) to be reachable before starting. This update greatly reduces connection issues, but does not guarantee that all resources in the PN are reachable.
You can follow these solutions to ensure reliable connectivity at startup.
Solution 1: Implement connection retry logic (recommended)
-
Configure connection retries: If your function tries to connect to a resource in the PN at startup, implement retry logic with configurable timeouts.
-
Configure startup probes: Set up the function startup probe to return a
200status code only when all required PN resources are reachable. This prevents traffic from being routed to a function instance before it is fully ready. -
Set appropriate timeouts: Configure connection timeouts to allow sufficient time for the network to become available (up to 3 minutes).
Solution 2: Use dedicated Private Networks
The issue rarely occurs when both the function and the resource it needs to reach are in different PNs (but within the same VPC).
- In a VPC, create a PN dedicated to your functions.
- Place your functions in this dedicated PN.
- In the same VPC, create another PN for the resources your functions need to reach (databases, Instances, etc.).
- Place the resources in this separate PN.
Solution 3: Use a different region
If you can, deploy your functions in a different region to avoid this issue.
Going further
- Use Private Networks with Serverless Functions
- Functions and Private Networks integration
- Monitor function logs and metrics
- Serverless Functions concepts