Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

PHP mail causing PHP5-FPM to time out
New on LowEndTalk? Please Register and read our Community Rules.

PHP mail causing PHP5-FPM to time out

winstonwinston Member
edited September 2012 in Help

It seems that every time PHP calls mail() it will make the page load forever, and eventually leading to a 504 NGINX timeout.

I have little to no clue of where to begin debugging this, help would be very appreciated.


  • Anything in your php log files?

  • I think it has something to do with the sendmail package (this is Ubuntu 12.04 x86 btw)

    service sendmail restart

    It takes about 2 minutes for the following to say [OK]

    • Restarting Mail Transport Agent (MTA) sendmail
  • cat /var/log/php5-fpm.log shows nothing besides restarts

  • You're checking the wrong log.

    Anyway, fpm echos errors to stdout, so nginx catches them on the fcgi interface.

    Look at your error log for that specific vhost in nginx.

  • 2012/09/30 01:50:34 [error] 27470#0: *87576 upstream timed out (110: Connection timed out) while reading response header from upstream, client: myip, server: mydomain.yay, request: "POST /?action=login HTTP/1.0", upstream: "fastcgi://", host: "mydomain.yay", referrer: "http://mydomain.yay/"

  • Nothing specific about mailing?

    Could it be that it's simply being overloaded? (Though, I guess that'd notify you in php5-fpm.log)

    I think you can change the verbosity of the log in php5-fpm.conf, try doing that.

  • This isn't WHMCS by any chance?

  • @Wintereise No way it's overloaded, only happens when mail is sent. SMTP mail works fine. service sendmail restart also hangs for several minutes. Also, can't find php5-fpm.conf..

    locate php5-fpm.conf


  • @jhadley said: This isn't WHMCS by any chance?

    Nope :(

  • May it have something to do with changing the VPS hostname?

  • the configuration is in the pool directory
    probably something like /etc/php/fpm/pool.d/www.conf

  • WintereiseWintereise Member
    edited September 2012
    ; Log level
    ; Possible Values: alert, error, warning, notice, debug
    ; Default Value: notice
    ;log_level = notice

    This is the directive I was talking about. And no, you don't have this in the pool config, but rather the global php-fpm configuration file.

    For me, it's

    [email protected]:/mnt# locate php-fpm.conf


  • Try using mail() in cli. for example, php -r "mail(...);" and try to find out it works or not.

  • mikhomikho Member, Host Rep

    Does sendmail actually start ?

    If its not running that would explain the timeout for php and we can shift focus to troubleshooting sendmail. Instead.

  • You can try out other mail transfer agents too, if the problem is indeed with Sendmail.

  • @Wintereise it was actually where @qjq said it was, should I be setting it to error or debug?

    @likexian it hangs just as long

    @MikHo yeah, it just takes a few minutes for it to start up

    @Wintereise anything you would recommend? Something that would require little setting up on my end, as all I wish to do is send mail without pages dying :<

  • Does the maillog show any warnings/errors, especially when you restart sendmail?

    I haven't used sendmail for years, but if the old hostname is set in the sendmail config, and that hostname no longer resolves, then there will likely be issues with sendmail....

  • Sep 30 16:00:01 saturn sm-msp-queue[12177]: My unqualified host name (saturn) unknown; sleeping for retry

    Sep 30 16:01:01 saturn sm-msp-queue[12177]: unable to qualify my own domain name (saturn) -- using short name

  • @sleddog ding ding ding! Updated /etc/hosts and it worked, thanks!

  • Lol, I believe the sendmail installer (when run via apt) actually tells you if your server hostname resolves and if it should be updated.

    Glad to see you've gotten it fixed though :)

  • @winston said: ding ding ding! Updated /etc/hosts and it worked, thanks!

    Cool you fixed it :)

Sign In or Register to comment.