How to fix 504 Gateway Timeout errors: I gathered all troubleshooting steps
The final nail in the coffin occurs when you’re having the worst tech day imaginable. You’re rushing to get a job done and get a 504 bad gateway error message. Great! What do you do now?
The first step is, don’t panic. I’m on hand with a helpful deep dive that will explain precisely what is 504 Gateway Timeout, why it occurs, and all the steps you can take to fix it.
What is 504 Gateway Timeout?
Let’s start with a quick explainer. A 504 Gateway Timeout error on a Mac simply means that your computer couldn't get a response from a server it was trying to access to complete a web request.
The server acting as a gateway took too long to respond, and this caused the connection to time out. More often than not, they’re a short-term issue if there’s high server traffic or a known issue with the remote server.
How to fix 504 Gateway Timeout errors
There are various fixes for 504 Gateway Timeout errors, which I’ll run through now, along with some practical hints and software.
Look for server connectivity issues
Take a look at your proxy server settings and ensure they’re correct. I’ll show you an easy way to do it, which is via Terminal.
Here’s what to do:
- Go to Finder > Applications > Utilities > Terminal.
- Type networksetup -getwebproxy Wi-Fi > Press Return. This shows the current proxy settings for your Wi-Fi network. For Ethernet, replace "Wi-Fi" with "Ethernet".
- Type networksetup -setwebproxy Wi-Fi proxy.server.address 8080 to modify proxy settings > Press Return.
- Replace proxy.server.address with your proxy’s address and 8080 with the appropriate port.
- Make sure that the settings match your network’s requirements.
Reboot your network devices
Try resetting your modem and any other network devices to see if that does the trick. Sometimes, all it takes is refreshing your network connections. This will revert everything back to its default settings and get you back on track.
Plus, you can stay on top of your signal and network connection by using WiFi Signal. It monitors your network and generates a graph that’s viewable live with a click on the app’s menu bar icon. So far, things are cool for me:
Check for any DNS issues / flush DNS caches
Sometimes, if you can’t connect to the internet, it’s worth taking a look at your DNS cache to see if there are any reasons why you can’t get online. Performing a flush is a way of getting rid of old or outdated files that are blocking your ability to connect to the internet.
To flush the DNS cache on a Mac:
- Go to Finder > Applications > Utilities > Terminal.
- Type sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder > Press Return
- Enter your admin password.
If you want to know more, check the detailed guide on flushing the DNS cache.
Sift through your logs
If you can gain access to your logs, then it’s worth checking them to see if there are any messages relating to the 504 error that can be traced and fixed.
Here’s what to do:
- Open the Console app (Finder > Applications > Utilities).
- Click the play button to run a scan.
- Check if there are any Log messages. Console will show all log messages and recent system activity.
- Search and filter by typing in a phrase to find a specific log message or activity.
- Then, filter to narrow down results by process, message, date, time, and more.
- Then, sort logs by column to help identify errors more easily.
Fix faulty firewall configurations
There might be times when your firewall is playing up, and you’re not sure why. Sometimes, it’s simply down to software conflicts or web pages taking too long to respond, but it’s a good idea to know how to resolve the issue, and I’ll show you what to do.
Firstly, disable your firewall temporarily. If, after doing this, the site loads, then the hosting server firewall blocks it.
To disable the firewall on a Mac:
- Click the Apple menu > System Settings.
- Click Network > Firewall.
- Turn off and on Firewall.
Check your proxy settings
Proxy server settings can block access to certain pages by their IP address. So, suddenly, a website you’d had no issues accessing before might become unusable. Therefore, you might want to disable them.
To disable proxy settings on a Mac:
- Go to the Apple menu > System Settings > Wi-Fi.
- Choose your Wi-Fi network > Details.
- Click the Proxies tab.
- Turn off the protocols you want to disable.
- Click OK to apply the changes.
After turning off the proxy settings, check if the error persists. If so, continue with my troubleshooting steps.
Comb through your website’s code to find bugs
A 504 Gateway Timeout can also be caused by malicious bots crawling websites. If that happens, server resources are compromised, and everything either slows down or stops. If your website is attacked by bots and the server stops responding, then you will get an HTTP 504 error.
Use Proxyman to analyze and debug network traffic. It’s a speedy way to identify bugs on Mac, iOS Simulator, or remote devices. It’s helped me when I’ve had to debug, and I’ve also noticed it keeps my battery life stable.
Contact your hosting provider
If you’ve tried all of the above and the tips still haven’t been quite enough to resolve your issues, then it’s time to contact support for help and assistance.
There is a good chance that the support team will help you fix the error code 504 and give you guidance on troubleshooting it.
504 Gateway Timeout reasons
It’s hard to pinpoint what’s causing the server timeout, and there are multiple reasons why a 504 error might occur, so you need to rule each one out until you find the actual cause.
It can be:
- DNS problems: Incorrect DNS settings or overloaded servers prevent your Mac from connecting to websites.
- Poor network: Bad internet connection, unstable network, or issues with routers lead to timeouts.
- Server issues: If there’s high traffic, websites can take too long to respond to requests.
- Firewall problems: Restrictive firewall settings on your Mac or server can block connections.
- Proxy settings: Having an incorrect proxy configuration on your Mac will result in delays in communication with servers.
- Bugs and bots: Bugs in the website's code, misconfigured server settings, or even traffic from bots can cause issues.
- CDN issues: Problems with a Content Delivery Network (CDN) used by the website can lead to 504 errors.
Final thoughts on fixing 504 gateway timeout errors
From checking your DNS cache to a simple reboot and restart, there are some quick and easy fixes to remove a 504 bad gateway from your Mac.
Often, these steps are enough to get you up and running again in no time. I think some solutions, like WiFi signal, WiFi Explorer, Proxyman, or Simon, can help ensure your connection stays stable all the time.
Why not check out these apps and 250 more on Setapp with a free 7-day trial? It's a fantastic platform for anyone who loves finding new, handy tools for fixing problems or for beginners who could use a little extra help.
FAQ
Is a 504 Gateway Timeout my fault?
They’re never your fault. The 504 Gateway Timeout issue usually points to an issue with the server you're trying to access, such as slow response times or server overload. When the server doesn't respond in the expected timeframe, you'll encounter this error.
How long does 504 Gateway Timeout last?
A 504 Gateway Timeout will only last as long as the server's configured timeout setting. This is usually about a minute. The length of time might depend on the server configuration, so the server might wait for a response from another server for another minute or so before giving up and displaying the 504 error message.
Is 504 Gateway Timeout a virus?
The 504 Gateway Timeout error message isn’t a virus. It’s a legit HTTP status code which means there’s a network issue in which the server couldn't get a response from another server. It’s down to issues with the site you’re trying to access and not a bug or bot.