There are all kinds of mysterious errors you might get when visiting websites online. The most famous one is probably 404 — the error you encounter when trying to visit a non-existent webpage. The second most popular one is a 504 bad gateway error. There are also dozens of others.
Being greeted with such errors when trying to load websites is frustrating, both for visitors and brands. Visitors don’t get the information they were looking for, while brands reduce their exposure and alienate their audience.
Good news is the error code 504 is somewhat under your control, and you can maintain your reputation by taking a few precautions and learning how to quickly fix the 504 gateway timeout issue when it comes up. But first, let’s specify what the 504 bad gateway error actually means and what are the reasons for it.
What is 504 gateway timeout?
Any time you visit any website, your server is trying to communicate with the host server (also known as upstream server) of that website to get all the necessary information to display the website’s content.
When the host server doesn’t respond back with the requested data fast enough, the request gets timed out, and you won’t be able to load the webpage correctly. This is the 504 gateway timeout error.
Depending on your browser and operating system, you might see different versions of the 504 error:
Google Chrome just says HTTP ERROR 504 followed by “This site can’t be reached.”
Apps in Windows might say HTTP_STATUS_GATEWAY_TIMEOUT or even WU_E_PT_HTTP_STATUS_GATEWAY_TIMEOUT
Another possible message can be “The proxy server did not receive a timely response from the upstream server.”
Unfortunately, the error code 504 itself is not that specific, and there can be plenty of reasons for it to appear, which makes the troubleshooting process somewhat complex.
Why 504 gateway timeout happens
Before you start fixing the 504 bad gateway error, you need to think through all the possible causes for it and try to deduce which one is responsible for the error this time around.
Servers can’t connect to each other. The most obvious reason for 504 error is failure at the website host server. It could be down because of an overload, attack, or maintenance, for example.
Changes in DNS. Moving your server to a different IP address would cause it to change the DNS as well. Since it takes some time for DNS to propagate, your website might be unavailable during that time. This situation should resolve itself within a day.
A strict firewall. Given that there’s so much malware online, leaving your website open to any bot or malicious script is not a good idea. Setting up a firewall can prevent illegitimate traffic and DDoS attacks, but can also sometimes reject real visitors, showing them the 504 bad gateway error.
Website errors. If you’ve been recently making changes and updating the code on your website, it’s possible that you’ve introduced some incompatibilities that your server can’t work with.
Network issues. Most of the time, 504 errors have to do with the host server. But if you’re the only one who is seeing the error page, it could point to an unresolved problem with your own internet connection.
Going through the various reasons above one by one can help you detect the real cause of the 504 gateway timeout error. With that information in mind, you can then easily find an appropriate solution.
How to fix 504 gateway timeout errors
If you look closely at all the possible reasons for the error code 504, the solution is likely to reveal itself. Here are some of the most popular fixes.
Troubleshoot server connectivity. Your server can go down without you even knowing it, resulting in 504 errors for all your visitors. It might be a quick server maintenance by your hosting company, or it might be a more serious and long-lasting bug with the server itself. To spot such, what you need is Simon.
Simon is a smart app that automatically monitors the state of all your servers and websites in one place. This app has a full toolkit to seamlessly help you control and troubleshoot your internet properties. You can set up monitoring systems, design various tests, detect any changes, find errors, and track recoveries. Notifications are also immediate, which means less downtime for anything you’re tracking.
Restart your network devices. Even though it has become quite a cliché fix, rebooting your network hardware is probably one of the best ways to fix network-related problems. Locally, start with your modem, router, and any switches. Remotely, you can restart your server or rebuild your website once again.
Reconfigure your DNS. One of the most common reasons for the 504 bad gateway to appear is having your website be in the process of moving to a new server and thus changing your DNS. DNS changes can take anywhere from a few hours to even a few days. After you make sure your DNS settings are correct, your best bet is to simply wait until that DNS is fully propagated online.
Find errors in server logs. If your server, network device, and DNS are fine, the problem might be more localized. Log in to your server and check the server logs to find any inconsistencies that could be causing the 504 bad gateway in the server status updates.
Tweak your firewall configs. Even though using a firewall is a really good idea, sometimes it might give you headaches with blocking legitimate traffic, which would result in the error code 504.
Locally on your Mac, make sure that your firewall is turned off in System Preferences ➙ Security & Privacy ➙ Firewall. Then navigate to the firewall settings in your server and try to deactivate them as well to test whether the 504 gateway timeout persists. If it’s gone, try turning the firewall settings back one by one to find the faulty one.
Ensure your proxy settings are correct. Most Macs don’t really use custom proxy settings, so this might not apply to everyone. But if you do, double-checking them could fix the 504 issue, especially if you debug them with Proxyman.
Proxyman is the best debugging Mac app for proxy settings. You can categorize various apps that communicate with the web as well as all the domain names you own, view HTTP/HTTPS requests, and look through potential errors on Mac, iOS simulator, or remote devices. Effortless proxy debugging indeed.
Check your website’s code. Rarely do you see a codebase with zero bugs in it. And while most bugs are inconsequential, some can interfere with the way your server is processing various requests. Look at your git commits first to see if there were any code additions that had anything to do with the server. If your web environment is pretty difficult to decipher, try DevUtils.
DevUtils is an extensive toolkit for building and testing websites locally on your Mac. It’s a great all-in-one solution for developers to have complete control over their website before pushing it out into the world.
Contact your hosting company. If you’re not well-versed in server configuration, you should try talking to your hosting provider and see what kind of support they can offer.
As you can see, once you know what is 504 gateway timeout, it’s all about methodically trying various solutions to fix the error. What would definitely help you is monitoring your website for any errors proactively with Simon, checking proxy settings with Proxyman, and testing your builds before deploying them with DevUtils.
Best of all, Simon, Proxyman, and DevUtils are all available to you absolutely free for seven days through the trial of Setapp, a platform with over 220 outstanding Mac apps for any task at hand. Try every Setapp app today at no cost and quickly assemble a collection of new favorites!