502 Bad Gateway on Frontend After Update to beta 3 (from 2)

Created on 25 July 2025, 30 days ago

Drupal Version: 10.4.7

Domain module version: 2.20.0-beta 3

We are encountering 502 Bad Gateway errors on all front end pages of our site following a rebuild of our composer.lock file witch auto upgraded the Domain module from 2.0.0-beta2 to 2.0.0-beta3. I suspect it has something to do with our hosting platform set up for Edge/Varnish (on Acquia) as it works find in my simple local dev environment.

The issue only affects the front end of the site; the Drupal admin area is fully functional.

Steps Taken So Far:

  • Verified domain records in Domain Access are valid.
  • Cleared Drupal cache (drush cr).
  • Cleared Acquia Varnish cache.
  • Verified domains are properly listed in Acquia Cloud UI.
  • Confirmed settings.php trusted host patterns are correct.
  • No circular redirects are present (curl -I -L confirms).
  • Logs show 502s but no PHP errors related to Domain Access.

Symptoms:

  • Admin pages (/admin/*) load fine.
  • Any content routed through Domain Access on the frontend returns 502.
  • 502 is consistent across all affected domains.
  • Same site codebase works without issue outside of Acquia.

Any thoughts on where to start debugging would we greatly appreciated. I've included all i see in the various logs below.

thanks,
summer

drupal-request srv-6776 [25/Jul/2025:22:55:36 +0000] support-stage.foresightsports.com GET /support http_code=200 query= uid=1 php_pid=26443 php_time=0.238 queue_wait=0 request_id="v-7a326146-69aa-11f0-9ae1-27b5762bee0e" drupal_version="10.4.7"
drupal-request srv-6776 [25/Jul/2025:22:55:36 +0000] support-stage.foresightsports.com GET /support http_code=200 query= uid=1 php_pid=26443 php_time=0.238 queue_wait=0 request_id="v-7a326146-69aa-11f0-9ae1-27b5762bee0e" drupal_version="10.4.7"
apache-request srv-6776 98.176.50.241 - - [25/Jul/2025:22:55:36 +0000] "GET /support HTTP/1.1" 103 6181 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0" vhost=foresightsportswmybz9vtih.devcloud.acquia-sites.com host=support-stage.foresightsports.com hosting_site=foresightsportswmybz9vtih pid=12173 request_time=260768 forwarded_for="98.176.50.241" request_id="v-7a326146-69aa-11f0-9ae1-27b5762bee0e" location="-"
varnish-request bal-6155 {"time": "[25/Jul/2025:22:55:36 +0000]", "status": "502", "bytes": "150", "method": "GET", "host": "support-stage.foresightsports.com", "url": "/support", "query": "", "referrer": "-", "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0", "client_ip": "98.176.50.241", "time_firstbyte": "0.241351", "hitmiss": "miss", "handling": "pass", "forwarded_for": "98.176.50.241", "request_id": "v-7a326146-69aa-11f0-9ae1-27b5762bee0e", "ah_log": "", "ah_application_id": "", "ah_environment": "", "ah_trace_id": ""}
bal-request bal-6155 127.0.0.1 - - [25/Jul/2025:22:55:36 +0000] "GET /support HTTP/1.1" 502 300 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0" status=502 bytes=300 http_host=support-stage.foresightsports.com affinity="-" upstream_addr="10.0.3.123:80" hosting_site=foresightsportswmybz9vtih request_time=0.241 forwarded_for="98.176.50.241" upstream_status="502" request_id="v-7a326146-69aa-11f0-9ae1-27b5762bee0e" ssl_protocol="-" ssl_cipher="-" 
πŸ’¬ Support request
Status

Active

Version

2.0

Component

Miscellaneous

Created by

πŸ‡ΊπŸ‡ΈUnited States summerg

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @summerg
  • πŸ‡ΊπŸ‡ΈUnited States summerg
  • πŸ‡©πŸ‡ͺGermany Bruno2

    https://www.drupal.org/project/domain/issues/3539748 πŸ› Internal Server Error when editing/viewing nodes after PHP upgrade Active

    Can you check if the error disappears if you modify the files as a test? I had a similar problem.

  • πŸ‡«πŸ‡·France mably

    I'm not sure what should be done here.

    May be you should stick to 2.0.0-beta2 for now.

    I'm leaving this open in case other people have encountered the same problem.

  • πŸ‡¬πŸ‡§United Kingdom intrafusion Edinburgh, UK

    This is also affecting us, but locally during development.

    In our local logs we found:

    NGINX Error: Upstream sent too big header while reading response header from upstream

    Further debugging found that one developer altered http.response.debug_cacheability_headers in development.services.yml from true to false, but another developer had to completely disable development.services.yml</code in <code>settings.local.php for these 502 errors to disappear.

    Hope this may aid finding where the actual problem lies

  • πŸ‡«πŸ‡·France mably

    @intrafusion, have you tried increasing NGINX proxy_buffer_size setting?

    Did you notice any change in your page http headers between 2.0.0-beta2 and 2.0.0-beta3?

  • πŸ‡¬πŸ‡§United Kingdom Povilas Uogintas

    Hi team,
    To provide some additional context, while investigating an issue, I discovered that the method \Drupal\domain_config\DomainConfigOverrider::getCacheableMetadata is adding cache tags for all possible configurations at the line:

    $metadata->addCacheTags(['config:' . $config_name['domain'], 'config:' . $config_name['langcode']]);
    

    When this line is enabled, it generates cache tags for every potential site configuration. For example:

    {
      "langcode": "domain.config.gb.en.field.storage.paragraph.field_horizontal_position",
      "domain": "domain.config.gb.field.storage.paragraph.field_horizontal_position"
    }

    If I comment out this line, the site returns to normal performance. With logging enabled, I can confirm that the code is producing an excessive number of cache tags, which appears to be the cause of the issue.

    In short, this use of `addCacheTags` is leading to performance problems by tagging every possible config, rather than only the relevant ones.

    Hope this gives some clues

    P.S. our site is huge and has vast amount of configs

  • πŸ‡«πŸ‡·France mably

    Thanks @povilas-uogintas for the hint, I'll have a look a it.

  • πŸ‡«πŸ‡·France mably
  • πŸ‡«πŸ‡·France mably
  • πŸ‡¬πŸ‡§United Kingdom Povilas Uogintas

    Hi @mabli,

    At the moment, until I fully understand the rationale why this has been added to ALL configs (or to very, very many of them), my initial thing will be either:

    1. To turn off completely, aka uncomment it out // probably not the best approach
    2. Add another config form where specific configs can be selected to which these cacheTags will need to be added.

    Do you think this makes sense?

  • πŸ‡«πŸ‡·France mably

    I think the cache tags should only be added to the overridden configs.

    I'll work on a patch on the original issue.

  • πŸ‡«πŸ‡·France mably

    @povilas-uogintas could you give a try to the following MR and see if it fixes your problem? Thanks.

    https://git.drupalcode.org/project/domain/-/merge_requests/161

  • πŸ‡¬πŸ‡§United Kingdom Povilas Uogintas

    Hi @mably,

    I have just applied the patch and everything seems to be working.

    Many thanks!

  • πŸ‡«πŸ‡·France mably

    I'll add a small test and merge it. Thanks for the review!

  • πŸ‡«πŸ‡·France mably

    Fix has been merged to 2.0.x-dev branch.

    @intrafusion @bruno2 could you give it a try and see if it solves your problem?

  • πŸ‡«πŸ‡·France mably
  • πŸ‡«πŸ‡·France mably

    And @summerg too.

  • πŸ‡©πŸ‡ͺGermany Bruno2

    I've given you a rewrite to clean up the code, and here are the differences from the current file. I found an older version (https://github.com/agentrickard/domain/blob/8.x-1.x/domain_config/src/Do...) that's readable, but this file is a mess, sorry!

    Cleaner code:
    - readable
    - better error handling with try/catch,
    - better cache cleanup and memory manage

    Better performance:
    - it loads multiple the configs, instead one by one
    - fewer database calls
    - avoid memory leaks

    Disabling the cache tag does not fix the other problems.

  • πŸ‡«πŸ‡·France mably

    @bruno2 not sure to understand what you are talking about.

    Are you saying that 502 errors are still present with latest 2.0.x-dev?

  • πŸ‡©πŸ‡ͺGermany Bruno2

    Thats not the point. I told you these small fix can not solve the whole errors with this file! It's trash and needs to be cleaned up, especially because it's loaded so frequently.

    Look for these bad pattern:
    \Drupal::languageManager(); // Bad - should not loaded directly, only if needed.
    \Drupal::service('domain.negotiator'); // Bad - hard to test

    Other Problems:
    - Loads configs one at a time (slow)
    - No proper cache cleanup
    - Static variables that can cause memory leaks -> line 122 static $lookups; // will not cleared and can be growing endless
    - Hard to Read // Complex nested if/else statements

  • πŸ‡«πŸ‡·France mably

    I'm closing this as fixed for now.

    @bruno2 feel free to open new dedicated issues for the other points you mention.

    And provide complete and documented MRs that pass all the module's tests (or adapt them accordingly).

  • πŸ‡³πŸ‡±Netherlands idebr

    Ran into this issue as well after updating to beta3. The issue was fixed in the -dev version, but the change to does apply cleanly as a patch

    #3538150-18: 502 Bad Gateway on Frontend After Update to beta 3 (from 2) β†’ mentions

    And if everything is ok, I'll publish a 2.0.0-beta4 release.

    A new beta version should prevent other sites from running into this issue, so a new release tag would be very welcome

  • πŸ‡«πŸ‡·France mably

    Hi @idebr, it's definitely on my todo list.

    Just trying to include a few more issues before releasing beta4.

Production build 0.71.5 2024