WordPress表单插件Ajax请求504网关超时问题求助
Hey there, let’s tackle this tricky 504 timeout issue you’re hitting with all three form plugins. It’s odd that emails go through successfully but the Ajax request hangs until it times out—this usually means the backend completes the email send but gets stuck somewhere before it can send a success response back to the frontend. Since you’ve already tweaked nginx and php-fpm settings, let’s dig into other likely culprits:
Email delivery is blocking the Ajax request
Most WordPress form plugins run email sends synchronously during the Ajax call. If your email server (Sendmail, Postfix, or a third-party SMTP service) is slow to process or acknowledge the send, it can cause the PHP script to hang until it hits the timeout limit. Try switching to an SMTP plugin to handle email delivery asynchronously, or check if your hosting provider has email delivery delays. Also, verify if your email service requires extra authentication steps that are causing a lag.PHP process gets stuck on post-email tasks
After sending the email, plugins often run additional actions like saving form entries, triggering webhooks, or executing custom code via hooks. If one of these actions fails or takes too long, it’ll block the response. Try:- Disabling any custom code snippets related to form submissions (check your theme’s
functions.phpor custom plugins). - Turning off post-submission features in each form plugin (entry saving, webhooks, redirects) to see if the timeout disappears.
- Testing database performance—run a quick insert query in phpMyAdmin to see if saving form entries is slower than usual.
- Disabling any custom code snippets related to form submissions (check your theme’s
Hidden server resource limits beyond nginx/php-fpm
Even if you adjusted nginx’sproxy_read_timeoutand php-fpm’smax_execution_time, there might be other limits overriding your settings:- Check your hosting provider’s global PHP limits by creating a
phpinfo.phpfile with<?php phpinfo(); ?>and verifying values likemax_execution_time,memory_limit, andmax_input_time(some hosts force their own values). - Look into server-level timeouts, like Apache’s
Timeoutsetting (if using Apache behind nginx) or cloud load balancer timeouts (AWS, GCP, etc.)—these can override your nginx configurations.
- Check your hosting provider’s global PHP limits by creating a
Plugin or theme conflicts (even across all three form tools)
Just because all three plugins are affected doesn’t rule out a common conflicting plugin or theme. Try:- Switching to a default WordPress theme (like Twenty Twenty-Four) temporarily to rule out theme-related issues.
- Disabling non-form plugins one by one, testing the form after each disable, to spot the conflicting tool.
Enable detailed logging to pinpoint the hang
Without logs, it’s hard to know exactly where the process gets stuck. Enable:- PHP error logging: Set
log_errors = Onanderror_log = /path/to/php-error.login your php.ini, then check the log after triggering the timeout. - nginx error logs: Look in
/var/log/nginx/error.logfor entries related to timeouts or proxy errors. - Form plugin logs: All three tools have built-in logging (CF7 has debug mode, WPForms logs under Settings > Tools, Ninja Forms logs in Advanced Settings). Enable these to see if the plugin reports errors after sending the email.
- PHP error logging: Set
Test asynchronous form submission
If possible, configure the plugins to handle submissions asynchronously. Some offer this via add-ons or settings—for example, CF7 has async options, and WPForms can use background processing for email sends. This way, the Ajax call returns immediately, and email/entry processing happens in the background.
Hopefully one of these steps helps you track down the root cause. It’s likely a slow process hanging the PHP script after the email is sent, so focusing on post-submission tasks or email delivery latency should lead you to a fix.
内容的提问来源于stack exchange,提问作者Leavlzi

