- Newest
- Most votes
- Most comments
Based on the information provided, it appears that you're experiencing an issue with WebSocket connections through CloudFront to your internal Application Load Balancer (ALB) using a VPC origin. The OriginDnsError you're seeing for WebSocket (wss) requests suggests that CloudFront is having trouble resolving the DNS for your origin when handling WebSocket connections.
This issue is likely not a bug in CloudFront, but rather a configuration problem. Here are a few things to check and consider:
-
Ensure that your CloudFront distribution is properly configured to handle WebSocket connections. This includes:
- Setting the "Allowed HTTP Methods" to include all methods (especially GET and OPTIONS for WebSocket handshake)
- Configuring the distribution to forward all headers to the origin
- Setting appropriate timeout values for origin response and connection
-
Verify that your VPC origin configuration in CloudFront is correct:
- The VPC ID, subnet IDs, and security group IDs should be accurately specified
- The origin domain name should be set to your internal ALB's DNS name
-
Check that your internal ALB is properly configured to handle WebSocket connections:
- Ensure that the appropriate target group is set up for WebSocket traffic
- Verify that the security groups allow the necessary inbound traffic from CloudFront
-
Review your VPC DNS settings:
- Make sure DNS hostnames and DNS resolution are enabled for your VPC
- Check if there are any custom DNS settings that might interfere with name resolution
-
Examine your ALB and target group health checks to ensure they're passing and that the targets are healthy
-
Consider using CloudFront's origin shield feature, which can help with origin connection issues in some cases
-
Review your WebSocket application code to ensure it's properly handling the connection and any potential errors
If after checking these items the issue persists, you may want to engage AWS support for further investigation, as there could be subtle networking or configuration issues that are difficult to diagnose without deeper access to the infrastructure.
Remember that while regular HTTP requests are working, WebSocket connections have different requirements and may be more sensitive to certain configuration issues. The fact that you're seeing an OriginDnsError specifically for WebSocket connections suggests that there might be a problem with how CloudFront is attempting to establish these connections to your internal ALB.
Sources
Requests can't be served when sending requests to cloudfront alternate domain name | AWS re:Post
Requests can't be served when sending requests to cloudfront alternate domain name | AWS re:Post
502 errors while accessing CloudFront distribution that's connected to a load balancer | AWS re:Post
Use real-time logs - Amazon CloudFront
Standard logging reference - Amazon CloudFront
Most of this answer isn't relevant given that the question specifies that typical HTTP requests are working.
Facing a similar issue, the above answer doesn't help
Relevant content
- asked 3 years ago
- asked a year ago

Also have the same problem with VPC origin + ALB + Websocket. Tried a variety of configurations, no luck.
same problem with VPC origin + websocket.
Same here with CloudFront + VPC origin + Private ALB with websocket, giving OriginDnsError. Works fine with other HTTP requests (no websocket). Also, using a VPN to access the private ALB directly to bypass CloudFront, then websocket works.
Having the same issue: currently the only available solution is to convert our ALB from internal to internet-facing, and rollback CloudFront to classic ELB Origin instead of CloudFront VPC Origin...
Ok, to follow up. I have received confirmation from AWS that Cloudfront simply does not support web sockets + VPC origins at the moment. This is also stated on the docs here: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-vpc-origins.html#vpc-origin-prerequisites