502 no hosts available upstream

Have a similar error.
I have local gitlab installed, and here is my config in Caddyfile:
`
https://git.mysite {
log /caddyserver/logs/git.access.log
errors /caddyserver/logs/git.errors.log

    proxy / http://192.168.1.100:7080 {
        fail_timeout 300s
        transparent
        header_upstream X-Forwarded-Ssl on
    }
}

`
Randomly had error

502 Bad Gateway
And error in log file
11/Jul/2018:20:54:36 +0000 [ERROR 502 /admin/broadcast_messages] no hosts available upstream
11/Jul/2018:20:55:33 +0000 [ERROR 502 /admin/broadcast_messages] no hosts available upstream

Error disappear after some time(reload page after 3-5 minutes),or after restart docker container.

Hi @brainode,

You’ve enabled fail_timeout for your Proxy. Here’s the relevant documentation:

  • fail_timeout specifies how long to remember a failed request to a backend. A timeout > 0 enables request failure counting and is required for load balancing between backends in case of failures. If the number of failed requests accumulates to the max_fails value, the host will be considered down and no requests will be routed to it until failed requests begin to be forgotten. By default, this is disabled (0s), meaning that failed requests will not be remembered and the backend will always be considered available. Must be a duration value (like “10s” or “1m”).
  • max_fails is the number of failed requests within fail_timeout that are needed before considering a backend to be down. Not used if fail_timeout is 0. Must be at least 1. Default is 1.

https://caddyserver.com/docs/proxy

Since you’ve only nominated one backend server, a single backend error will make the proxy unavailable for 300 seconds (5 minutes), as per your configuration.

Oh, thanks… so dummy mistake from my side((

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.