Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Darren_Ter's avatar

503 error behind load balancer

My application is behind a digital ocean load balancer, but it seems like cannot found the routes I declared inside a route group :

Route::group(
[
   'domain' => '123.abc.com',
   'middleware' => ['auth', 'throttle:200,1']
],
function() {
   Route::get('/testing', function() {
     dd("I am found");
   });
});

When I navigate to 123.abc.com/testing, an error of 503 Service Unavailable. No server is available to handle this request occur. But as I remove 'domain' => '123.abc.com' from the route group, everything works well.

Another strange thing is, the error will be triggered even I access a route outside of the route group.

Route::get('/123', function() {
  dd("I am outside of route group");
 });

// route group here

Am I do any mistakes here? Also, is there any alternative way to make the route group accessible from "123.abc.com" only?

Extra notes :

  1. "123.abc.com" is pointing to the IP address of digital ocean load balancer
  2. The route group with "domain" works well if I point "123.abc.com" directly to droplet IP address
  3. My TrustProxies.php configurations :
protected $proxies = "*";
protected $headers = Request::HEADER_X_FORWARDED_ALL;
0 likes
1 reply
beko1997's avatar

Personally I haven't used load balancers on DO yet. But could it be that the healthcheck on the load balancer fails? If there aren't any servers available for handling the requests it will most likely return a 504 response. In that case the request does not get forwarded. When the health check fails you could try to add a fallback route (which returns 20x status) in order to get the health back up.

Another thing you can look into is the way DO is forwarding, is it set to passthrough? In that case the request will be redirected to the droplet without adding a header (x-forwarded-). The changes to the TrustProxies could be reverted.

You could also try to log the request()->getHost() (for example in your routes config file). Then you can check whether the host matches with 123.abc.com.

Please or to participate in this conversation.