The 502 Bad Gateway error for cloud-hosted webhook automation is typically caused by network accessibility issues. Here’s how to resolve all three focus areas:
Webhook Endpoint Accessibility:
First, verify your endpoint is reachable from HubSpot’s cloud infrastructure. The 502 error indicates the gateway cannot connect to your upstream server. Check that your partner system’s webhook endpoint:
- Accepts HTTPS connections (HTTP-only endpoints often fail in cloud environments)
- Has a valid SSL certificate (self-signed certificates will be rejected)
- Returns a response within 30 seconds
Test connectivity from an external service like webhook.site to simulate cloud-to-cloud communication:
// Test webhook endpoint availability
curl -X POST https://api.partner-system.com/webhooks/contact-update \
-H "Content-Type: application/json" \
-d '{"test": "connectivity"}'
IP Whitelisting Configuration:
This is the most common cause of 502 errors after cloud migration. HubSpot’s cloud environment uses specific outbound IP ranges that differ from on-premise installations. Contact HubSpot support to get the exact IP ranges for your region, then whitelist them in your partner system’s firewall.
For hs-2022 US-hosted environments, the typical ranges are:
52.72.0.0/16
54.88.0.0/16
34.224.0.0/16
Update your firewall rules to allow these ranges. In your partner system’s network configuration:
// Pseudocode - Firewall rule update:
1. Access firewall management console
2. Navigate to inbound rules for webhook endpoint
3. Add rule: Allow TCP port 443 from HubSpot IP ranges
4. Apply and test immediately
// Verify in firewall logs that connections are now accepted
Reverse Proxy Timeout Settings:
If your partner system uses a reverse proxy (nginx, Apache, AWS ALB), ensure timeout settings accommodate the additional network latency from cloud-to-cloud communication. Update your proxy configuration:
For nginx:
upstream partner_webhook {
server backend:8080;
keepalive_timeout 65;
}
location /webhooks/ {
proxy_connect_timeout 10s;
proxy_send_timeout 30s;
proxy_read_timeout 30s;
}
After implementing these changes, test the webhook from HubSpot’s workflow automation. Create a simple test workflow that triggers the webhook with minimal data. Monitor both HubSpot’s workflow logs and your partner system’s access logs to confirm successful delivery. The 502 errors should resolve once IP whitelisting and proxy timeouts are properly configured.