Allow Websocket connections on Google Cloud Platform

We have a GCE project, with several servers behind a loadbalancer. The servers are running a NodeJS HTTPS server. We have recently tried to implement websocket support, but can't seem to connect to it from behind the loadbalancer. As soon as the upgrade header gets sent to the server to initiate the websocket, it closes the connection with a 400 error.

In the loadbalancer's logs we see the following:

  @type:  "type.googleapis.com/google.cloud.loadbalancing.type.LoadBalancerLogEntry"   
  statusDetails:  "upgrade_header_rejected"   

The connection doesn't seem to go through to our backend servers. Does anyone know how to solve this?


WebSocket is natively supported by the HTTP(s) load balancers in GCP. If you are using that load balancer and you are receiving the “upgrade_header_rejected” message is probably because the backend rejected the connection. It is also possible that the client tried to upgrade from a secure connection to an insecure one or that the header is an invalid one.