Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using mail() causes 504 Gateway Time-out in Nginx

I just installed php, mysql, nginx, sendmail on debian 6.

Now the PHP pages work fine. But when I try to use a simple mail() test:

Example: mail($to, $sub, $msg)

it takes too long to finish (around 30+secs) then get I 504 Gateway Time-out in my browser.

Funny thing is the email is actually sent.

BTW this is the error from the log: upstream timed out (110: Connection timed out) while reading response header from upstream

Anybody knows what's causing this error?

like image 290
IMB Avatar asked Oct 18 '12 14:10

IMB


People also ask

How do I fix Nginx timeout?

504 Gateway Timeout Error on Nginx + FastCGI (PHP-FPM) ini . Open the file and add/change the value for the max_execution_time directive to 300 seconds. Reload Nginx and PHP-FPM for the changes to take effect.

What causes nginx timeout?

Nginx 504 - Timeout error One of the most common reasons for a 504 Gateway Timeout error is a server problem. If your web server is running on Nginx, for example, and you are receiving an Nginx 504 error, then you can try increasing a few of your config settings.

What causes a 504 Gateway Timeout?

A 504 Gateway Timeout Error means your web server didn't receive a timely response from another server upstream when it attempted to load one of your web pages. Put simply, your web servers aren't communicating with each other fast enough.


1 Answers

I think the problem in your sendmail. I recommend to install Postfix instead of sendmail and configure it in php.ini. Then check your mail() function.

Also you can try to use sendmail directly instead of using mail- function.

like image 85
Sergei Shitikov Avatar answered Sep 22 '22 08:09

Sergei Shitikov