Everything you need to know about this HTTP code
Are you encountering a 504 Gateway Timeout error when trying to visit a website? This is definitely a frustrating issue, especially if you're not sure what this error means or how to fix it (but it's likely not your fault!). In this article we'll go over what a 504 Gateway Timeout error is, how to fix it (for users and website owners), and some common error messages you may see instead of just "504 Gateway Timeout."
Ways to Fix a 504 Gateway Timeout Error
- Refresh the page
- Check your network settings (including proxies, firewall, and VPN)
- Flush the DNS cache
- Restart your router and/or modem
- Restart your computer
- Wait until the website owner fixes the issue
Steps
Section 2 of 4:
Fixes for Website Users
-
Refresh the page. The first thing to try is refreshing the page. The 504 error may be due to a random glitch, and refreshing the page can fix that error.
-
Check your network settings. If you use a proxy or a VPN , try temporarily disabling them. You may also want to check your firewall settings to ensure your settings aren't set too strictly.
- On Windows, search for "proxy" or "firewall" in the taskbar search bar to pull up your proxy or firewall settings. You can also search for "network troubleshooter" to use the built-in troubleshooter to fix any network issues.
- On Mac, open the Apple menu and go to System Settings > Network . Choose either Proxies or Firewall to edit these settings.
- If you have a VPN, each VPN program will be set up slightly differently. Open your VPN program and look for an option or toggle to turn it off.
-
Flush your DNS cache. If your network settings seem normal, you can try flushing your DNS cache . This can resolve some network connectivity issues and will remove old, bad, and corrupt data from your DNS cache.
- Windows: Search "cmd" in the taskbar search bar, then right-click Command Prompt and select Run as administrator . Then, type ipconfig /flushdns and press ↵ Enter to flush your DNS.
- Mac: Press ⌘ Cmd + Space and search for the Terminal app, then open it. Type sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder . Press ⏎ Return and enter your admin password.
-
Restart your router and/or modem. If you're getting 504 errors on every site, the problem may be with your network devices. Unplug your router and/or modem from the wall for at least 30 seconds, then plug it back in. Once your internet connection is restored, try accessing the site again.
- Many people have combination routers and modems, so you'll only need to unplug one device.
-
Restart your computer. If restarting your router and/or modem doesn't fix the issue, you can try restarting your entire computer. While it may not seem like it, restarting your computer can fix a whole host of seemingly random issues, including network issues that cause problems accessing websites.
-
Wait it out. If nothing else works, the issue is likely server-side and must be fixed by the website owner.
- If you can access other web pages on the site or know the website's contact info, you can contact the site to report the error.
- You can also check with your ISP to see if the issue is on their end.
Advertisement
Section 3 of 4:
Fixes for Website Owners
-
Check your DNS propagation. If you recently transferred your website to a different server, your domain's DNS may not be propagated fully yet. Use https://dnschecker.org to see if your site's DNS is propagated.
- You may want to also check your domain's DNS settings to ensure there are no errors.
-
Disable your CDN. If you use a CDN like Cloudflare, you may want to try temporarily disabling it if you're encountering 504 errors on your site. The CDN could be causing the error by not giving a timely response to the origin server's request.
-
Check for spam or DDoS attacks. If malicious bots are spamming your website, it can lead to all visitors getting a 504 error. Check your site's access logs to see if there's an influx of suspicious IPs visiting your site, then block them.
- If you encounter a lot of DDoS attacks, consider using DDoS protection. Many cloud services, including Cloudflare, Amazon Web Services, and Microsoft Azure, offer DDoS protection.
-
Extend your API request timeout limit. If you're using NGINX, you may be encountering 504 errors due to your API calls taking too long to complete. If this is the case, you can extend your API request timeout limit.
- Go to
/etc/nginx/sites-available/default
or/etc/nginx/nginx.conf
. - Add the following:
-
proxy_connect_timeout 240;
-
proxy_send_timeout 240;
-
proxy_read_timeout 240;
-
send_timeout 240;
-
- Run sudo nginx -t to check syntax.
- Run sudo service nginx restart . [2] X Research source
- Go to
Advertisement
Expert Q&A
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
Advertisement
Tips
Submit a Tip
All tip submissions are carefully reviewed before being published
Name
Please provide your name and last initial
Thanks for submitting a tip for review!
References
About This Article
Thanks to all authors for creating a page that has been read 4,525 times.
Advertisement