Skip to content
FunnelGuard

Fix guide by FunnelsGuard

504 Gateway Timeout on form submit: how to find and fix it

PRF-062High impactDetectedBy FunnelGuardPublished Updated
On this page

What this issue is

When someone presses Submit, the browser sends a request to an endpoint on your site, such as /wp-admin/admin-ajax.php, /wp-json/..., a Webflow or GoHighLevel form handler, or your own /api/lead route. Between the browser and your application there is usually a proxy: Cloudflare, nginx, a load balancer or your host's gateway.

Where a 504 breaks the lead journey
  1. Visitor fills formPage loads and fields work
  2. Submit requestBrowser posts to the endpoint
  3. Proxy waits for appSlow email, CRM or database call
  4. Thank-you page and trackingNever reached, conversion not recorded
  5. Lead in inbox / CRMMay be missing or partial

The proxy times out while waiting for the app, so nothing after the submit step happens.

Why it costs you leads or sales

Lead loss from a timing-out formExample numbers
Lead loss from a timing-out form (example)Healthy form: 100 leads per week; With 504s: 80 leads per week0387710080Healthy formWith 504sleads per week

Example: 100 people press Submit each week. With a 20% timeout rate, only 80 leads arrive.

How to check if your site has it

Confirm the 504 on submit
  1. Open DevTools on the form page

    In Chrome press F12, open the Network tab and tick Preserve log.

  2. Submit the form with test data

    Use a clearly fake name and an email address you control.

  3. Find the POST request

    Filter by Fetch/XHR or Doc. A status of 504, or a request that hangs for a long time and then fails, confirms the timeout. Note the URL and the Time column.

  4. Check the response headers

    Headers such as server: cloudflare or server: nginx show which layer gave up. A Cloudflare 504 page names Cloudflare as the one that timed out.

  5. Look at server logs

    Search the nginx or host error log for upstream timed out and the PHP or app log for slow or fatal entries at the same time.

  6. Repeat at a busy time

    Try again during peak traffic or when backups and cron jobs run, since load often triggers it.

Time a form POST from the command linebash
curl -s -o /dev/null -w "status=%{http_code} total=%{time_total}s\n" \
  -X POST https://example.com/wp-admin/admin-ajax.php \
  -d "action=your_form_action&name=Test&email=test@example.com"

How to fix it

Common causes of a form 504 and the fix
CauseSignFix
Slow SMTP or mail API callLog shows delay at mail sendUse a transactional mail service or queue the email
Slow CRM or webhook callHangs on an outbound HTTP requestSet a short client timeout and send in the background
Heavy database querySlow query log entriesAdd indexes, clean tables, upgrade resources
Too few PHP workersRequests queue under loadIncrease workers or upgrade the plan
Proxy timeout too lowWork is legitimately longRaise the timeout after fixing the slow step
Firewall or origin blocking proxy504 only through CDNAllow the CDN's IP ranges, check origin health
General fix order
  1. Identify the slow step

    Use logs or temporary timing logs around the mail, CRM and database calls.

  2. Move slow work out of the request

    Save the lead first, respond to the visitor, then send email and CRM calls from a queue or background job.

  3. Set timeouts on outbound calls

    Give every third-party call a short timeout (for example 5 to 10 seconds) so one slow service cannot hold the whole request.

  4. Add server capacity if needed

    If requests queue, raise PHP workers or app processes, or move to a larger plan.

  5. Raise the proxy timeout last

    Only as a safety margin once the slow step is fixed.

Fix by platform
  1. Find the slow plugin

    Install Query Monitor and submit the form. Check slow queries and HTTP API calls made during the request. Temporarily disable add-ons on the form plugin (CRM, spam or payment add-ons) to isolate the culprit.

  2. Replace default PHP mail

    Use an SMTP or mail API plugin so sending does not stall the request.

  3. Raise PHP limits if justified

    Ask your host to check max_execution_time and PHP-FPM workers. Many managed hosts set these in their panel.

nginx: raise timeouts for one endpoint onlynginx
location = /api/lead {
    proxy_pass http://app_backend;
    proxy_connect_timeout 5s;
    proxy_read_timeout 60s;
}

# PHP-FPM sites use this instead:
# fastcgi_read_timeout 60s;

How to confirm it's fixed

After the fix
  • The submit POST returns 200, 201, 202 or a redirect, not 504
  • The response time is a few seconds at most
  • The thank-you page or success message appears
  • The test lead arrives in your inbox and CRM exactly once
  • The conversion tag fires on the thank-you step (check in GA4 DebugView or the Tag Assistant)
  • The form still works when tried at a busy time
  • No new 'upstream timed out' entries in the error log

How to prevent it happening again

Prevention habits
  • Always put short timeouts on calls to third-party services
  • Queue email and CRM work instead of doing it inside the request
  • Schedule backups and heavy cron jobs away from campaign hours
  • Retest the form after every plugin, theme or hosting change
  • Keep a fallback: save every lead to your database before any external call
  • Monitor the real submit flow on a schedule, not just uptime of the homepage
How an unnoticed 504 unfolds
  1. Day 1

    A CRM add-on update makes each submit wait on a slow API call.

  2. Day 2

    Under load some submits pass 60 seconds and return 504. The homepage still loads, so uptime checks stay green.

  3. Day 5

    Ad spend continues, leads and conversions drop. (Example timeline.)

  4. Day 6

    Someone notices fewer enquiries and investigates.

  5. Day 6

    Slow call moved to a queue, form responds in about a second.

How FunnelGuard handles this

Submit hits a server error

The visitor presses Submit, the proxy times out and the lead never arrives.

Questions people ask

Why is my form giving a 504 Gateway Timeout when I submit?

A proxy, CDN or load balancer in front of your site waited for your server to answer the form request and gave up. The usual cause is a slow step inside the request, such as sending email, calling a CRM or running a heavy database query. Check your server error log for 'upstream timed out' to see which one.

What is the difference between a 502 and a 504 on a form?

A 504 means the gateway got no answer in time. A 502 means it got an invalid response or the application crashed. Both lose the submission, but a 504 points to slowness and a 502 points to a crash or misconfiguration.

How do I fix a 504 error on a contact form in WordPress?

Use Query Monitor to see what the submit request does, then disable form add-ons one at a time to find the slow one. Switch to SMTP or a mail API for sending, and ask your host to check PHP workers and execution time. Retest the form after each change.

Should I just increase the timeout to fix a 504?

Only as a last step. A higher timeout makes visitors wait longer and lets slow requests pile up. Fix or move the slow work first, then raise the limit on that endpoint as a safety margin.

Why does the form only time out sometimes?

Intermittent 504s usually follow load or a slow third party. Backups, cron jobs, traffic peaks or a CRM having a bad moment can each push a normal request past the limit. Test at different times and check logs for the failing timestamps.

Do I lose the lead when a form returns a 504?

Often yes, but not always. The server may finish the work after the proxy gave up, so the lead can arrive late or twice. Because you cannot rely on that, save leads to your database before calling external services.

Can a 504 on submit affect my ad tracking?

Yes. If the thank-you page never loads, conversion tags for Google Ads, GA4 or Meta do not fire, so the platforms record fewer conversions than you really got.

How can I be alerted when my form starts returning 504?

Run a synthetic check that submits the form on a schedule and alerts when the submit step fails. FunnelGuard does this, re-checking from a second region before sending one alert with a screenshot and a likely cause.

Does FunnelGuard catch this?

Detected

FunnelGuard checks for this today.

How: submit step fails.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.