Nginx 504 Error when trying to use PHPMailer

Posted February 9, 2018 4k views
NginxPHPEmailUbuntu 16.04

I’ve been trying to send an e-mail using PHPMailer but have been getting a “504 Gateway Time-out” error.

Did a bit of research and I think it’s because nginx is trying to use IPv6. I thought the solution was to try to make it use IPv4 was the solution.

Tried to do the following already:
echo 'Acquire::ForceIPv4 "true";' > /etc/apt/apt.conf.d/99force-ipv4
echo 'precedence ::ffff:0:0/96 100' >> /etc/gai.conf
service nginx restart

Still getting the same issue and I can’t find anything else that I could try.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hi @drcmanansala,

It’s impossible to pinpoint the exact issue without checking the error logs of Nginx. The problem could be a million things from permissions,ownership to a problem with the Nginx configuration preventing to work with PHPMailer.

I’ll recommend before you make any changes whatsoever, to check the Nginx error log and see the exact error you are getting.