Kong gRPC Routing Issue - HTTP/2 Requests Getting 400 Errors
Problem
Trying to route gRPC traffic through Kong, but all gRPC requests fail with 400 errors while HTTP routing works fine.
Environment
Kong 3.4.3.21 (open source)
Kubernetes deployment
Service exposes ports 80 and 443
What Works
Direct gRPC to backend: grpcurl -plaintext localhost:50051 list
HTTP routing through Kong: curl http://localhost:8080/world
Kong Admin API on port 8001
What Fails
gRPC through Kong:
grpcurl -plaintext localhost:8080 list
Error: "Failed to dial target host: context deadline exceeded"
Backend gRPC service is healthy and works directly. Only routing through Kong fails. Any help appreciated! Moreover, my HTTP services are working well with kong.
Kong must be explicitly configured to accept HTTP/2 traffic on the proxy port for gRPC to work. By default, Kong listens for HTTP/1.x unless you add the http2 suffix to the proxy_listen (or KONG_PROXY_LISTEN) configuration. If this is not set, gRPC clients will fail to connect, and you’ll see the exact error and log pattern you described.
Make sure http2 has been added to 1 of the below parameters
e.g proxy_listen = 0.0.0.0:8000 http2, 0.0.0.0:8443 http2 ssl KONG_PROXY_LISTEN = 0.0.0.0:8000 http2, 0.0.0.0:8443 http2 ssl
Please remember to restart Kong after you modified any of them how to proxy gRPC request via kong
Solution
Update Kong’s proxy listener to support HTTP/2:
If you’re running Kong in Kubernetes, set the environment variable for the deployment:
This is a standard setup for gRPC routing in Kong.
Additional Notes
gRPC requires HTTP/2: If Kong is not listening for HTTP/2, all gRPC requests will fail with 400 errors, as you observed.
Kong 3.6.x and later: If you upgrade, simultaneous HTTP/1.1 and HTTP/2 without TLS on the same port is supported. For Kong 3.4.x, you may need to dedicate a port for HTTP/2 if you also need HTTP/1.1 on port 80. gRPC over HTTP
Summary
Update your proxy_listen or KONG_PROXY_LISTEN to include http2, restart Kong, and your gRPC routing should work as expected.
If you continue to see issues after this change, please provide the updated listener configuration and any new error logs.
Great @Abdul_Matin . For questions I encourage you to checkout out our AI assistant at https://developer.konghq.com/. I have been feeding your questions into the agent to get this information. I posted your follow up question to the agent and got this back:
Yes, Kong Gateway can serve both HTTP/1.x and HTTP/2 over the same port, but with some important caveats:
For HTTPS (TLS) ports: You can serve both HTTP/1.x and HTTP/2 on the same port using the http2 ssl suffix in your proxy_listen configuration. This works because TLS allows protocol negotiation (ALPN), so clients and Kong can agree on which protocol to use for each connection. For example:
proxy_listen = 0.0.0.0:8443 http2 ssl
With this configuration, both HTTP/1.x and HTTP/2 clients can connect to port 8443, and Kong will handle both protocols appropriately over TLS connections. This is the recommended and most widely supported approach for serving both protocols on the same port Does Kong support http2 protocol?.
For plain HTTP (non-TLS) ports: By default, NGINX (and therefore Kong) does not support serving both HTTP/1.x and HTTP/2 on the same non-TLS port. HTTP/2 without TLS (h2c) requires “prior knowledge” from the client, and NGINX only supports one protocol version per plain HTTP port. If you configure a port for HTTP/2 (e.g., 0.0.0.0:8000 http2), only clients that use HTTP/2 with prior knowledge can connect; HTTP/1.x clients will not be able to use that port, and vice versa Does Kong support http2 protocol?, gRPC over HTTP.
Recent Kong versions: Starting with Kong Gateway 3.6.x, there is support for listening to both HTTP/1.1 and HTTP/2 without TLS on the same port, but only in those versions and later. For earlier versions, you must use separate ports for HTTP/1.x and HTTP/2 if you want to support both protocols without TLS gRPC over HTTP.
Summary:
For HTTPS: Yes, both HTTP/1.x and HTTP/2 are supported on the same port.
For HTTP (no TLS): Only supported on the same port in Kong Gateway 3.6.x and later; otherwise, you need separate ports.
If you need to configure this, use the proxy_listen directive as shown above.