Issues with setting up Grpc in Caddy Config

1. Caddy version (caddy version): Caddy:2.4.6-alpine

2. How I run Caddy:

a. System environment:

b. Command:

Paste command here.

c. Service/unit/compose file:

Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane.

d. My complete Caddyfile or JSON config: {
        handle_path /service1/* {
            reverse_proxy localhost:8080
        handle_path /service2/* {
            reverse_proxy h2c://localhost:8081
        handle_path /service3/* {
            reverse_proxy localhost:8082

3. The problem I’m having:

I am trying to setup up Caddy to reverse proxy to our GRPC service that is run in docker, at localhost:8081.

When ever I try to hit the service we get a unexpected EOF error in the Caddy log and nothing comes through the service.

4. Error messages and/or full log output:

  "level": "error",
  "ts": 1641972868.5600731,
  "logger": "http.log.error",
  "msg": "unexpected EOF",
  "request": {
    "remote_addr": "",
    "proto": "HTTP/2.0",
    "method": "POST",
    "host": "",
    "uri": "/dataStreaming.DataStreaming/PausePlayer",
    "headers": {
      "X-Grpc-Web": [
      "Content-Type": [
      "Sec-Fetch-Site": [
      "Accept-Encoding": [
        "gzip, deflate, br"
      "Accept-Language": [
      "X-User-Agent": [
      "Accept": [
      "Origin": [
      "User-Agent": [
        "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) bloom-rpc-client/1.5.3 Chrome/78.0.3904.130 Electron/7.1.11 Safari/537.36"
      "Sec-Fetch-Mode": [
      "Content-Length": [
    "tls": {
      "resumed": false,
      "version": 772,
      "cipher_suite": 4865,
      "proto": "h2",
      "proto_mutual": true,
      "server_name": ""
  "duration": 0.003767059,
  "status": 502,
  "err_id": "ctn3v34jc",
  "err_trace": "reverseproxy.statusError (reverseproxy.go:886)"

5. What I already tried:

I tried doing it this way as well just for a test without needing specify the service name. Same issue {    
         reverse_proxy h2c://localhost:8081

6. Links to relevant resources:

Sounds like you’re running in Docker. Are you sure localhost will reach that service? Proxying to localhost will typically only reach servers running inside the same container (unless you use the host networking mode).

Turn on debug mode by adding this at the top of your Caddyfile, then check your logs again. It’ll probably show a more detailed message:

1 Like

Thank you for you help :slightly_smiling_face:. We resolved our issue, there was an issue in our service

What was the issue exactly, in case someone else runs into this thread with the same problem?

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.