Skip to content
Home » Nginx 504 | Nginx Bad Gateway 504 답을 믿으세요

Nginx 504 | Nginx Bad Gateway 504 답을 믿으세요

당신은 주제를 찾고 있습니까 “nginx 504 – Nginx Bad Gateway 504“? 다음 카테고리의 웹사이트 https://hu.taphoamini.com 에서 귀하의 모든 질문에 답변해 드립니다: https://hu.taphoamini.com/photos/. 바로 아래에서 답을 찾을 수 있습니다. 작성자 webprog24 이(가) 작성한 기사에는 조회수 992회 및 좋아요 7개 개의 좋아요가 있습니다.

nginx 504 주제에 대한 동영상 보기

여기에서 이 주제에 대한 비디오를 시청하십시오. 주의 깊게 살펴보고 읽고 있는 내용에 대한 피드백을 제공하세요!

d여기에서 Nginx Bad Gateway 504 – nginx 504 주제에 대한 세부정보를 참조하세요

In this tutorial you will find help is your server is facing a 504 Bad Gateway Nginx server issue. The full article about the 504 Bad Gateway 504 issue you will find here https://www.webprog24.com/fixing-504-bad-gateway-nginx-error After watching the video you will be able to fix the Bad Gateway 504 timeout issue for nginx.

nginx 504 주제에 대한 자세한 내용은 여기를 참조하세요.

Sửa lỗi 504 gateway time-out nginx [NHANH NHẤT] – Nhân Hòa

Thử dùng browser khác để sửa lỗi 504 gateway time-out nginx · Tải lại trang hay Refresh website · Kiểm tra Plugin nhằm sửa lỗi 504 gateway time- …

+ 여기에 더 보기

Source: nhanhoa.com

Date Published: 1/4/2022

View: 4666

Prevent nginx 504 Gateway timeout using PHP set_time_limit()

I am getting 504 timeouts message from nginx when my PHP script is running longer than usual. set_time_limit(0) does not seem to prevent that!

+ 여기를 클릭

Source: stackoverflow.com

Date Published: 9/25/2022

View: 2920

504 gateway time-out error – IBM

A 504 error means nginx has waited too long for a response and has timed out. There might be multiple reasons for the problem. Possible fixes include:.

+ 여기를 클릭

Source: www.ibm.com

Date Published: 9/26/2022

View: 6009

How to Fix 504 Gateway Timeout using Nginx – Easy Cloud

It is very common to see a 504 Gateway Timeout error using Nginx webserver. This timeout error is generated often by a number of reasons on …

+ 여기를 클릭

Source: easycloudsupport.zendesk.com

Date Published: 11/12/2022

View: 7144

Lỗi 504 Gateway Time-out là gì? Cách khắc … – Mona Media

Lỗi này khi hiển thị trong cửa sổ trình duyệt có rất nhiều dạng: 504 Gateway Time-out Nginx; Gateway Time out Error; HTTP Error 504 …

+ 자세한 내용은 여기를 클릭하십시오

Source: mona.media

Date Published: 1/13/2022

View: 7357

How to Fix 504 Gateway Timeout Error in NGINX – Ubiq BI

When you use NGINX as reverse proxy server and it times out waiting for a response from back end web servers, it sends a 504 Gateway Timeout …

+ 여기에 보기

Source: ubiq.co

Date Published: 7/18/2021

View: 3224

How to Fix the 504 Gateway Timeout Error Code – Kinsta®

Server issues are one of the most common reasons for facing a 504 Gateway Timeout error. Since most WordPress sites are hosted on Nginx or …

+ 여기에 표시

Source: kinsta.com

Date Published: 5/14/2022

View: 5445

Làm thế nào để sửa lỗi 504 gateway time-out trong WordPress

504 gateway timeout Nginx xảy ra do nhiều nguyên do liên quan đến việc phân phối nội dung phía backend. Thường do server hoạt động dưới dạng gateway hoặc proxy …

+ 자세한 내용은 여기를 클릭하십시오

Source: www.hostinger.vn

Date Published: 11/21/2022

View: 4113

Nginx reverse proxy causing 504 gateway timeout

The 504 Gateway Timeout error is one of the most common errors that website owners and visitors encounter, This HTTP status code is sent …

+ 여기에 보기

Source: thietkewebhcm.com.vn

Date Published: 2/3/2021

View: 7157

504 Gateway Timeout NGinx – DigitalOcean

I am running into a 504 gateway timeout error with my express API. … I added the client_header_timeout config to nginx.config but that …

+ 자세한 내용은 여기를 클릭하십시오

Source: www.digitalocean.com

Date Published: 10/2/2021

View: 7783

주제와 관련된 이미지 nginx 504

주제와 관련된 더 많은 사진을 참조하십시오 Nginx Bad Gateway 504. 댓글에서 더 많은 관련 이미지를 보거나 필요한 경우 더 많은 관련 기사를 볼 수 있습니다.

Nginx Bad Gateway 504
Nginx Bad Gateway 504

주제에 대한 기사 평가 nginx 504

  • Author: webprog24
  • Views: 조회수 992회
  • Likes: 좋아요 7개
  • Date Published: 2018. 11. 6.
  • Video Url link: https://www.youtube.com/watch?v=aMLmIPMBrKI

Sửa lỗi 504 gateway time-out nginx [NHANH NHẤT]

Hà Kiều Oanh

Hà Kiều Oanh 22/04/2021, 02:34 pm

22/04/2021, 02:34 pm 3,009

Bạn đã khi nào gặp phải lỗi 504 gateway time-out nginx chưa? Bạn hiểu thế nào về lỗi 504 và cách sửa lỗi 504 gateway time-out nginx ra sao? Hãy cùng Nhân Hòa tìm hiểu ngay trong bài viết dưới đây, hãy theo dõi nhé!

1. Bạn hiểu lỗi 504 gateway time-out nginx là gì?

Trước khi đi vào tìm hiểu rõ hơn về cách sửa lỗi 504 gateway time-out nginx, bạn cần năm rõ thông tin về lỗi 504 này và trường hợp nào sẽ gây ra lỗi 504.

Mã trạng thái HTTP Status Codes xuất hiện khi không nhận được phản hồi kịp thời từ máy chủ đang truy cập trong lúc đang tải một trang web hoặc thực hiện một yêu cầu khác từ trình duyệt thì sẽ dẫn đến lỗi “The 504 Gateway Timeout”.

Hay bạn có thể hiểu đơn giản, lỗi 504 thường xuất hiện khi một máy tính hay một trang web không phản hồi trong khoảng thời gian quy định.

Vấn đề có thể không nằm ở máy tính hay thiết bị hoặc kết nối internet của bạn. Vì lỗi này thường là lỗi mạng giữa các máy chủ trên internet hoặc sự cố với máy chủ thực.

Cách thức hiển thị lỗi 504 gateway time-out nginx

Tương tự với những trang web bình thường, lỗi 504 gateway time-out sẽ xuất hiện bên trong trình hiển thị trình duyệt internet. Chúng có thể hiển thị ở phần headers và footers rất quen thuộc với trang web hoặc một đoạn nhỏ tiếng Anh xuất hiện trên trang web, có đôi khi nó hiển thị trên một trang trắng với số 504 lớn ở đầu trang.

+ 504 Gateway Timeout

+ 504 ERROR

+ HTTP 504

+ Gateway Timeout Error

+ Gateway Timeout (504)

+ HTTP Error 504 – Gateway Timeout

Dù là xuất hiện dưới dạng nào, nhưng đó cũng là lỗi 504 gateway time-out nginx

Xem thêm: Lỗi 403 forbidden là gì? Nguyên nhân và cách sửa lỗi 403 forbidden

2. Đừng bỏ qua 09 cách sửa lỗi 504 gateway time-out nginx HOT này

Hãy cùng theo dõi phần tiếp của Nhân Hòa để có thể lựa chọn được cho mình cách sửa lỗi 504 gateway time-out nginx nhanh chóng và hiệu quả nhất.

Thử dùng browser khác để sửa lỗi 504 gateway time-out nginx

Cách đầu tiên và đơn giản nhất mà chúng tôi muốn giới thiệu để sửa lỗi 504 gateway time-out nginx đó là sử dụng trình duyệt khác.

Hãy thử dùng một trình duyệt khác, Nếu thấy website đang ở trạng thái hoạt động (Up/Active), nhưng vẫn thấy hiển thị 504 gateway timeout.

Xóa cache hoặc mở incognito mode khác cũng có thể giúp bạn xử lý nếu lỗi liên quan đến trình duyệt đang dùng.

Tải lại trang hay Refresh website

Có nhiều trường hơp do máy chủ nhận được quá nhiều yêu cầu hơn mức bình thường nên không thể xử lý kịp.

Để thực hiện sửa lỗi 504 gateway time-out bạn hãy chờ vài phút rồi tải lại trang hay còn được gọi là Refresh website.

Trong khoảng thời gian chờ đợi đó, bạn hoàn toàn có thể dùng công cụ kiểm tra website xem có bị Down hay không. Nếu website vẫn hoạt động bình thường thì lỗi là do máy Local chứ không phải do máy chủ.

Xem thêm: Localhost là gì? Hướng dẫn cài đặt local host nhanh nhất

Kiểm tra Plugin nhằm sửa lỗi 504 gateway time-out nginx

Cách sửa lỗi 504 gateway time-out nginx tiếp theo mà chúng tôi muốn giới thiệu đó là kiểm tra Plugin. Lỗi 504 cũng có xuất hiện khi 1 Plugin bị lỗi thời hoặc không tương thích. Để xác định lỗi 504 có phải do plugin hay không, bạn hãy thao tác vô hiệu hóa plugin nhé.

Thao tác vô hiệu hóa Plugin WordPress cũng khá đơn giản, bạn hãy tìm thư mục wp-content sau đó tiến hành đổi Folder Plugin thành tên khác là được.

Sau đó, xác định chính xác Plugin gây lỗi bằng cách đổi tên ngược lại với tên vừa đổi trước đó. Thực hiện vô hiệu hóa theo thứ tự từng Plugin.

Sửa lỗi 504 gateway time-out nginx bằng Flush DNS

Thật không khó để gặp trường hợp DNS cache bị lỗi thời hoặc sai dẫn đến lỗi 504 gateway time-out nginx. Khi gặp phải bạn hoàn toàn yên tâm vì chỉ cần Flush DNS là được.

Trong hệ điều hành khác nhau cũng sẽ có những cách xóa cache DNS khác nhau, nhưng nhìn chung thì việc đó đều rất dễ làm và nhanh chóng, bạn chỉ cần xem qua hướng dẫn flush DNS trên Windows, Linux, và MacOS một lần là làm được.

Xem thêm: [18K/THÁNG] Mua đăng ký thuê Windows Hosting [GIÁ RẺ #1 VIỆT NAM]

Kiểm tra Error Log

Để sửa lỗi 504 gateway time-out nginx hay kiểm tra Error Log. Việc cập nhật hoặc thay đổi mới các website cũng là nguyên nhân gây nên lỗi 504 gateway time-out.

Bạn hãy copy đoạn code sau đây vào file wp-config.php để sửa lỗi 504 gateway time-out nginx do Error Log nhé.

1 Define( ‘WP_DEBUG’, true );

2

3 Define( ‘WP_DEBUG_LOG’, true );

4

5 Define( ‘WP_DEBUG_DISPLAY’, false );

Sau khi hoàn thành hãy save lại các thông tin vào file wp-contents/debug.log

Điều chỉnh cấu hình máy chủ

Điều chỉnh cấu hình Server cũng là một cách sửa lỗi 504 gateway time-out nginx khá phổ biến.

Nếu bạn đang dùng VPS Hosting, bạn có thể điều chỉnh server hoặc nâng cấp một số tài nguyên.

Đối với máy chủ Nginx

File /etc/nginx/conf.d/timeout.conf => tăng giới hạn của các giá trị:

+ Proxy_connect_timeout 800

+ Proxy_send_timeout 800

+ Proxy_read_timeout 800

+ Send_timeout 800

Tại File php.ini bạn hãy tăng giới hạn max_execution_time

Save lại và khởi động Nginx

Thử truy cập lại website để kiểm tra việc sửa lỗi 504 gateway time-out nginx đã thành công hay chưa.

Đối với máy chủ Apache

Tại file httpd.conf bạn toàn quyền có thể tăng thời gian timeout mặc định lên. Ví dụ như:

# Timeout: The number of seconds before receives and sends time out.

Timeout 800

Bên cạnh đó, hãy tăng thêm giới hạn max_execution_time trong file php.ini:

max_execution_time 300

Khởi động apache và kiểm tra lại sau khi save lại thay đổi. Nếu nguyên nhân là do không đủ tài nguyên hoặc thời gian để xử lý thì đây là cách sửa lỗi 504 gateway timeout error hiệu quả nhất.

Kiểm tra CDNs để sửa lỗi 504 gateway time-out nginx

Bạn hãy kiểm tra chi tiết lại mọi thứ từ CDN của bạn nếu bạn đang dùng CDN để tăng tốc nội dung nhé.

Một trong số các lý do thường thấy là do CloudFlare, hoạt động như là một CDN và dịch giảm tấn công DDoS.

Trong quá trình sử dụng, bạn hoàn toàn có thể gặp 2 phiên bản 504 gateway time-out như sau:

+ Phiên bản lỗi 504 là do phía CloudFlare

+ Phiên bản thứ 2 là do liên quan đến nhà cung cấp web hosting.

Xem thêm: Mua đăng ký Cloud Hosting SSD giá rẻ – Web Hosting [36K/THÁNG]

Kiểm tra lại việc tải trang trên thiết bị khác

Nếu bạn sử dụng điện thoại di động để truy cập website bằng 4G thì nên thử truy cập lại website bằng thiết bị khác và trên một đường mạng khác.

Trường hợp truy cập bình thường có nghĩa là vấn đề do thiết bị bạn dùng truy cập website chứ không phải do máy chủ.

3. Liên hệ với nhà cung cấp Hosting

Lỗi 504 vẫn xuất hiện khi bạn đã thử tất cả các cách sửa lỗi 504 gateway time-out nginx trên thì bạn hãy liên hệ ngay với nhà cung cấp hosting của mình.

Nếu bạn đang sử dụng dịch vụ hosting tại Nhân Hòa hãy liên hệ ngay với chúng tôi và mô tả lại chi tiết toàn bộ quá trình bạn đã thực hiện sửa lỗi và tình trạng hiện tại để nhân viên kỹ thuật hỗ trợ bạn nhanh chóng nhất.

Nhân Hòa với 20 năm kinh nghiệm tự tin là đơn vị cung cấp dịch vụ công nghệ thông tin và giải pháp mạng chất lượng với giá cả phải chăng nhất. Đặc biệt, dịch vụ hỗ trợ khách hàng của công ty luôn làm khách hàng hài lòng và được sự tin tưởng của tất cả khách hàng đã đến với chúng tôi.

+ Tổng đài: 1900 6680

+ Website: https://nhanhoa.com/

+ Fanpage: https://www.facebook.com/nhanhoacom

+ Chỉ đường: https://g.page/nhanhoacom

+ Chương trình khuyến mãi mới nhất: https://nhanhoa.com/khuyen-mai.html

Prevent nginx 504 Gateway timeout using PHP set_time_limit()

There are several ways in which you can set the timeout for php-fpm. In /etc/php5/fpm/pool.d/www.conf I added this line:

request_terminate_timeout = 180

Also, in /etc/nginx/sites-available/default I added the following line to the location block of the server in question:

fastcgi_read_timeout 180;

The entire location block looks like this:

location ~ \.php$ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_read_timeout 180; include fastcgi_params; }

Now just restart php-fpm and nginx and there should be no more timeouts for requests taking less than 180 seconds.

504 gateway time-out error

If you are seeing 504 gateway time-out errors when running Transaction List Screening (TLS), your system might be low on resources. Increase your environment resources to resolve this issue.

A 504 error means nginx has waited too long for a response and has timed out. There might be multiple reasons for the problem.

Possible fixes include:

Increasing the nginx proxy_read_timeout default of five minutes to be longer, for example, to 10 minutes. The steps to do so are as follows:

Log into the OpenShift UI: https://:8443 On the right-hand side of the page click the project where FCI Platform Kubernetes was installed. Click Applications > Pods Find the FCI Common UI NGINX pod. It will have a name similar to fci-common-ui-nginx-xxxxxxxxxx-xxxxx Click on the Terminal tab. Change to the locations-files directory “` cd /etc/nginx/conf.d/location-files “` Change the nginx-location-fcai.conf file from: location /tls/api/v1 { proxy_pass https://fcai-fci-alerts-insight-tls-analytics:3333; client_max_body_size 20m; } To the following: location /tls/api/v1 { proxy_pass https://fcai-fci-alerts-insight-tls-analytics:3333; client_max_body_size 20m; proxy_read_timeout 600s; } This will change the read timeout to ten minutes (600 seconds). Run the following command to reload your changes: nginx -s reload

Lỗi 504 Gateway Time-out là gì? Cách khắc phục lỗi 504 nhanh chóng

Có bao giờ bạn bắt gặp lỗi 504 Gateway Time-out mà không biết được cách khắc phục nó không? Nếu câu trả lời là có thì bài viết này Mona Media sẽ cho bạn hiểu hơn về lỗi 504 Gateway Time-out và chỉ cho bạn cách giải quyết lỗi này nếu chẳng may gặp phải nhé!

Lỗi 504 Gateway Time-out là gì?

Lỗi 504 Gateway Time-out là một lỗi máy chủ (server) trả về khi không thể thực hiện được một yêu cầu nào đó do lỗi của một trong các HTTP Status Codes. Lỗi này ít xảy ra hơn lỗi 502 bad gateway error hoặc 500 internal server error. Chắc hẳn những ai truy cập Browsing trên internet cũng đã từng gặp phải lỗi 504 Gateway Time-out này.

Lỗi liên quan đến server thường nhận biết khi HTTP Status Codes bắt đầu bằng số “5”. Khi server bị mất liên lạc trong quá trình giao tiếp qua lại với nhau nhưng không hoàn tất yêu cầu sẽ có lỗi 504 Gateway Timeout. Server khi không nhận được phản hồi từ proxy hay từ server gateway khác, nghĩa là server không thể thực hiện yêu cầu trong thời hạn nhất định.

Lỗi 504 Gateway Time-out hiên thị như thế nào?

Lỗi này khi hiển thị trong cửa sổ trình duyệt có rất nhiều dạng:

504 Gateway Time-out Nginx

Gateway Time out Error

HTTP Error 504 – Gateway Time-out

504 Gateway Time-out

504 Error

Gateway Timeout (504)

Cách khắc phục lỗi 504 Gateway Time-out

Tải lại trang hoặc Refresh Website

Lí do có thể là vì máy chủ nhận được nhiều yêu cầu hơn bình thường nên không xử lý kịp. Cách đầu tiên để fix lỗi 504 Gateway Time-out là bạn phải chờ vài phút rồi tải lại trang (refresh website). Trong lúc đó hãy sử dụng công cụ kiểm tra website xem có bị Down không. Trường hợp website vẫn hoạt động bình thường thì là lỗi máy Local chứ không phải do máy chủ.

Sử dụng một Browser khác

Nếu lỗi 504 Gateway Time-out vẫn còn xuất hiện trong khi website hoạt động Up/ Active thì bạn nên thử dùng một trình duyệt web khác. Bạn hãy mở Incognito Mode hoặc thử xoá Cache, cũng là một cách xử lý lỗi có liên quan đến Browser đang sử dụng.

Flush DNS

Lỗi 504 Gateway Time-out đôi lúc xuất pháp từ việc DNS Cache bị sai hoặc quá cũ. Nếu đó đúng là nguyên nhân thì việc khắc phục cũng khá đơn giản. Bạn cần Flush DNS là có thể khắc phục được. Thế nhưng, bạn nên chú ý cách xoá Cache DNS trong mỗi hệ điều hành khác nhau. Đổi tạm thời DNS server thành Google Public DNS để xử lý lỗi HTTP Status Code nếu như nguyên nhân bắt nguồn từ DNS.

Kiểm tra lại việc trải trang trên thiết bị khác

Trường hợp bạn sử dụng điện thoại di động truy cập website bằng 4G thì hãy thử truy cập website lại bằng một thiết bị khác và trên một đường mạng khác. Nếu truy cập được bình thường thì là do thiết bị bạn dùng để truy cập website chứ hoàn toàn lỗi không từ máy chủ.

Kiểm tra Error Log

Cập nhật hoặc website mới thay đổi cũng có thể là một trong nguyên nhân gây lỗi 504 Gateway Time out. Nguyên nhân này có thể được khắc phục khá đơn giản, bạn có thể áp dụng cách thêm 3 dòng dưới đây vào file wp-config.php:

Define( ‘WP_DEBUG’, true ); Define( ‘WP_DEBUG_LOG’, true ); Define( ‘WP_DEBUG_DISPLAY’, false );

–> Lưu các thông tin vào file wp-contents/debug.log

Kiểm tra Plugin

Cũng có thể lỗi 504 Gateway Timeout là do Plugin lỗi thời hoặc không tương thích. Bạn thực hiện việc vô hiệu hoá Plugin sẽ giúp bạn biết được lỗi có liên quan đến Plugin hay không. Việc này cũng rất dễ. Vô hiệu hoá Plugin WordPress chỉ cần đến thư mục wp-content tiếp đế đổi Folder Plugin thành tên khác là xong. Tiếp đến, hãy xác định chính xác Plugin gây lỗi bằng cách đổi tên ngược lại với tên bạn vừa đổi trước đó. Hãy thực hiện vô hiệu hoá theo thứ tự cho từng Plugin.

Một số plugin WordPress thông dụng:

Kiểm tra CDNs

Nếu bạn sử dụng CDN để tăng tốc nội dung thì hãy kiểm tra nó vì rất có thể lỗi 504 Gateway Time-out bắt nguồn từ đây. Có khả năng do CloudFlare hoạt động như CDN và giảm tấn công DDoS. Nếu như lỗi là do CloudFlare thì bạn nên liên hệ cho nhà cung cấp nhằm được hỗ trợ. Nếu bạn vô hiệu hoá CloudFlare, hãy chờ vài giờ để DNS được quảng bá.

Điều chỉnh cấu hình máy chủ

Nếu bạn đang sử dụng VSP Hosting, hãy điều chỉnh server và nâng cấp một số tài nguyên.

Đối với máy chủ Apache

Vào File http.conf => sau đó tăng thời gian Timeout mặc định lên

=> sau đó tăng thời gian Timeout mặc định lên Vào File php.ini => để tăng giới hạn max_execution _time

=> để tăng giới hạn Lưu thay đổi

Khởi động Apache

Kiểm tra xem còn lỗi 504 Gateway Timeout không?

Đối với máy chủ Nginx

File /etc/nginx/conf.d/timeout.conf => tăng giới hạn của các giá trị:

Proxy_connect_timeout 600 Proxy_send_timeout 600 Proxy_read_timeout 600 Send_timeout 600

Trong File php.ini => hãy tăng giới hạn max_execution_time

=> hãy tăng giới hạn Lưu và khởi động Nginx

Thử truy cập website lại

Sửa lỗi 504 Gateway Time-out trên trang web của riêng bạn

Kiểm tra xem máy chủ bạn có thể phân giải đúng với tất cả các miền ứng dụng của bạn yêu cầu quyền truy cập hay không. Nếu lưu lượng truy cập quá lớn cũng có thể dẫn đến máy chủ bạn xuất hiện lỗi 504 mặc dù lỗi 503 có thể chính xác hơn.

Trong WordPress, thông báo “504: Gateway Time-out” có thể tại cơ sở dữ liệu bị hỏng. Bạn cài đặt WP-DBManager và sau đó hãy thử tính năng “Repair DB”, tiếp đến là “Optimize OB” xem có giúp ích được bạn không. Hãy đảm bảo tệp htaccess không có vấn đề gì, nhất là khi bạn vừa cài đặt lại WordPress.

Liên hệ với nhà cung cấp Hosting

Nếu đã thử tất cả cách ở trên nhưng lỗi 504 Gateway Time-out vẫn còn thì bạn nên liên hệ cho nhà cung cấp Hosting. Hãy mô tả chi tiết quy trình khắc phục và cung cấp các thông tin liên quan để nhân viên kỹ thuật tiến hành hỗ trợ nhanh hơn và hiệu quả hơn.

Lỗi 504 Gateway Time out có thể hiện thị theo cách khác

Trong Window Update, tạo mã lỗi 0x80244023 hoặc thông báo WU_E_PT_HTTP_STATUS_GATEWAY_TIMEOUT.

Ở các chương trình trên nền tảng Window tự truy cập internet, lỗi 504 hiển thệ trong hộp thoại nhỏ hoặc cửa sổ có lỗi HTTP_STATUS_GATEWAY_TIMEOUT và/hoặc với thông báo “The request was timed out waiting for a gateway”.

Một lỗi 504 ít phổ biến hơn là “Gateway Time-out: The proxy server did not receive a timely response from the upstream server”, nhưng cách khắc phục sự cố vẫn giống như cách trên.

Những lỗi giống lỗi 504 Gateway Time-out

Vì tất cả đều xuất hiện ở phía máy chủ nên một số thông báo lỗi cũng giống như “504 Gateway Time-out”. Số ít gồm lỗi 500 Internal Server, 504 Service Unavailable, lỗi 502 Bad Gateway,…

Ngoài ra còn các những mã trạng thái HTTP cũng không phải là phía máy chủ mà thay vào đó là phía máy khách, ví dụ như lỗi thường thấy là 404 Not Found.

Tham khảo thêm một số lỗi và cách khắc phục chúng:

Lời Kết

Đọc đến đây, chúng tôi tin rằng bạn đã có cho mình những cách khắc phục lỗi 504 Gateway Time-out và hiểu hơn về nguyên nhân có thể dẫn đến lỗi này. Chúc bạn thực hiện thành công và nhanh chóng

How to Fix 504 Gateway Timeout Error in NGINX

Users get 504 Gateway Timeout Error in NGINX when you use it as a reverse proxy server and it gets timed out waiting for a response from back end web servers. Here’s how to fix 504 Gateway Timeout error in NGINX.

What is 504 Gateway Timeout Error in NGINX

When you use NGINX as reverse proxy server and it times out waiting for a response from back end web servers, it sends a 504 Gateway Timeout error to client browser. This can happen due to various reasons such as application bugs, faulty plugins, poorly configured modules. Sometimes, it may be due to network issues and may get fixed automatically.

Bonus Read : How to Fix 502 Bad Gateway Error in NGINX

How to Fix 504 Gateway Timeout Error in NGINX

Here are some of the key ways to fix 504 Gateway Timeout Error in NGINX.

1. Server goes down

One of the most common causes for 504 bad gateway is that your back end server has gone down because it got overloaded with too many requests, or some long running requests. Such issues get fixed automatically when server load gets balanced. However, analyze server logs to identify the requested URLs just before your server went down, to optimize their code. Sometimes, it may also be a signal that you need to upgrade your server.

2. DNS issue

DNS issue can be on client side or server side. In case of server side DNS problems, the issue may be because your domain name doesn’t resolve to an IP, in case you have changed your website IP address or migrated your website to a new IP. In such cases, it may take anywhere between 5 minutes to 24 hours for the DNS records to be updated.

In case of client-side problems, try flushing local DNS cache.

Bonus Read : How to Increase Request Timeout in NGINX

3. Disable CDN

If your website uses CDN, it may sometimes timeout causing NGINX to return 504 Gateway Timeout error. In such cases, just disable your CDN and try accessing your website.

4. Network Connectivity

NGINX will also give 504 Gateway Timeout error if there are network connectivity issues between your reverse proxy server and back end web server. Log into your proxy server and try connecting to your web server using curl/ping command.

Bonus Read : How to Increase File Upload Size in NGINX

5. Firewall Issues

If your web server’s firewall is not properly configured it may block many requests causing NGINX to give 504 Gateway Timeout error.

6. Spams, Bots and DDOS attack

Sometimes malicious attackers may flood your web server with too many requests, or slow running requests. Monitor your server log to see if there is any spike in traffic, identify their IP address ranges and put measures in place to regulate their incoming requests.

Bonus Read : How to Hide NGINX Server Version From Header

7. Bugs and Faulty Plugins

Sometimes application bugs, faulty plugins and poorly configured modules can also slow down or bring down your server, causing NGINX to return 504 Gateway Timeout error. In this case too, you need to analyze server logs to find out which requested URLs are causing the issue and fix them soon.

Hopefully, the above tips will help you fix 504 Gateway Timeout Error in NGINX.

Ubiq makes it easy to visualize data in minutes, and monitor in real-time dashboards. Try it Today!

How to Fix the 504 Gateway Timeout Error on Your WordPress Site

The 504 Gateway Timeout error is one of the most common HTTP 5xx errors faced by website owners and site visitors. For many WordPress blogs and ecommerce platforms, knowing how to fix server errors like this is crucial to keep their hard-earned visitors from bouncing to competitor sites.

As the 504 Gateway Timeout error doesn’t tell you why it occurred, it’s hard to pinpoint what’s causing the server timeout. This article will help you understand it in detail, learn how to diagnose its cause, and then fix it.

After trying all the various solutions mentioned in the post, your site should be up and running in no time.

Sounds interesting? Let’s dive in!

Prefer to watch the video version?

The 504 Gateway Timeout error is one of the most common HTTP 5xx errors faced by website owners and site visitors. 🤔 Learn how to fix it with this guide quickly. ⬇️

Click to Tweet

What Is the 504 Gateway Timeout Error?

Every time you visit a website in your browser, the browser sends a request to the web server where the site is hosted. The server processes the request and responds with the requested resources.

See how Kinsta stacks up against the competition. Select your provider WP Engine SiteGround GoDaddy Bluehost Flywheel HostGator Cloudways AWS Digital Ocean DreamHost Other Compare

The server response includes one of many HTTP status codes to indicate the response’s status to the browser. But not all these HTTP status codes are errors. For instance, a 200 OK status code means that the server processed the request successfully and “Everything is OK.”

The 5xx class of HTTP status codes indicates that something’s wrong with the server, the server is aware of it, and it cannot carry out the client request. As a result, they’re also referred to as Server Error 5xx status codes.

Officially, five status codes are specified under the 5xx class (500, 501, 502, 503, 504). You may come upon many unofficial codes too (506, 507, 509, 520, etc.).

The Internet Engineering Task Force (IETF) defines the 504 Gateway Timeout error as:

The 504 (Gateway Timeout) status code indicates that the server, while acting as a gateway or proxy, did not receive a timely response from an upstream server it needed to access in order to complete the request.

To simplify it further, this error occurs when two servers are involved in processing a request. The first server (typically the main server) times out, waiting for a response from the second server (upstream server).

The 504 Gateway Timeout error manifests itself in various forms. Here are some ways it usually shows up:

The 504 Gateway Timeout error is similar to the 502 Bad Gateway error, which indicates that the first server received an invalid response from the second server (upstream server).

Variations of the 504 Gateway Timeout Error

The browser displays any 504 Gateway Timeout error inside it, just like any other error. As there are various operating systems, web servers, browsers, and user agents, it can show up in multiple ways.

Below are a few common 504 error message variations that you may run into:

504 Gateway Timeout

504 Gateway Timeout NGINX

NGINX 504 Gateway Timeout

Gateway Timeout Error

Error 504

HTTP Error 504

HTTP Error 504 — Gateway Timeout

HTTP 504

504 Error

Gateway Timeout (504)

This page isn’t working — Domain took too long to respond

504 Gateway Time-out — The server didn’t respond in time

The page request was canceled because it took too long to complete

Site visitors: There was an issue serving your request, please try again in a few minutes.

Site Owners: There was a gateway timeout. You should visit your error log for more information.

A blank white screen

All the above error responses, though worded differently, point to the same 504 Gateway Timeout server error.

Web servers and websites can customize how they show the 504 Gateway Timeout error to users. Some of them can be cool! It’s an excellent tactic to quell their visitors’ disappointment.

SEO Impact of the 504 Gateway Timeout Error

All 5xx errors prevent a webpage from loading, making them detrimental to user experience. Hence, search engines like Google take these errors seriously. If the error persists for a long duration, it may even lead to deindexing the webpage from the search engine results.

For example, when Google spiders stumble upon a 503 Service Unavailable error, they’ll understand that it’s a temporary issue as it’s mostly used to enable site maintenance mode. Thus, they’ll try to crawl the page again later.

A 504 Gateway Timeout error isn’t necessarily temporary as it can be due to multiple reasons. If your site is down for just a few minutes, and if the spiders are trying to crawl it multiple times every minute, they’ll try to serve the page from their cache. They wouldn’t even notice it.

But if your site is down for 6+ hours or more, then Google will consider the 504 error as a serious site-wide issue that you need to fix as soon as possible. This can impact your SEO negatively.

Google Search Console is one of the best SEO tools to monitor your website’s HTTP 5xx errors.

Causes of the 504 Gateway Timeout Error

As the 504 error is due to a timeout between servers, the problem probably isn’t with the client’s device or internet connection. That also includes your device and connection.

A 504 Gateway Timeout error indicates that the web server is waiting too long to respond from another server and “timing out.” There can be many reasons for this timeout: the other server is not functioning properly, overloaded, or down.

The other server need not always be external (e.g. CDN, API gateway). It can also be a server-like entity within the main web server (e.g. reverse proxy server, database server).

How to Fix the 504 Gateway Timeout Error

Without knowing exact details about the WordPress site, such as its server configuration, hosting plan, third-party plugins, and the traffic it attracts, you may find it frustrating and overwhelming to fix a 504 Gateway Timeout error.

Since many variables are involved, I recommend you to start by fixing client-side issues, which are pretty rare, and then move towards fixing server-side problems. They’re usually the culprits with 504 errors.

Try Reloading the Webpage

One of the first things you can try when encountering a 504 Gateway Timeout error is to wait a few minutes and try reloading the page.

You can press the F5 keyboard shortcut to refresh/reload the webpage in most browsers. To remove the page’s browser cache before reloading, you can press the CTRL+F5 shortcut combo instead.

While you’re at it, you can also try loading the site in a different browser to rule that out as an issue. As most 504 errors are due to temporarily overloaded servers, using this solution should make your site come right back.

If waiting and reloading the site doesn’t fix the 504 error issue, you can check whether a site is down for everyone or just you. Two useful online tools to test a site for downtime are Down for Everyone or Just Me and Is It Down Right Now?

Reboot Your Network Devices

Sometimes, problems with your network devices like modem or router could lead to a 504 Gateway Timeout error. Rebooting these devices could help you with fixing the problem.

While you can switch off all these networking devices in any order, the order you switch them back on is important. Typically, turn these devices on from the “outside-in,” following the connection order from the internet service provider to your main client device.

Check Your Proxy Settings

A proxy server sits between your device and the internet. It’s mostly used to enhance online privacy by hiding private information (e.g. device location) from websites and webservers (e.g. using a VPN).

While it’s rare for proxy servers to cause a 504 error, incorrect proxy server settings can sometimes be the reason. You can disable the proxy server and try reloading the webpage to see whether it’ll fix the error.

Most clients don’t use a proxy service, so you can skip this step if you’re confident that you don’t use any proxy server. However, you might have set it without you even knowing about it. I’d suggest you check your device’s and browser’s proxy settings to rule this cause out.

DNS Issues

A 504 Gateway Timeout error can also be caused by DNS issues on the server-side or the client-side (or both).

The most probable reason for a server-side DNS issue is the FQDN (fully qualified domain name) not resolving the correct IP address or the DNS server not responding. Usually, this occurs when you’ve just migrated your WordPress site to a new server or host. Hence, it’s important to wait for the domain’s DNS records to propagate fully, which can take up to 24 hours.

You can use free tools like whatsmydns.net DNS Checker or DNSMap to see if your DNS has propagated around the globe.

For fixing client-side DNS issues, you could try flushing your local DNS cache. It’s like clearing your browser cache, except here, you’re flushing the DNS cache from the operating system.

If you’re using Windows, you can flush the DNS cache by opening the Command Prompt and entering the following directive:

ipconfig /flushdns

You should see a “Successfully flushed the DNS resolver Cache.” message if it worked.

For the latest macOS versions, you can open the Terminal and run the following command:

sudo killall -HUP mDNSResponder

You won’t see any notification in macOS when the process finishes, but you can change that by appending the command with your custom message.

sudo killall -HUP mDNSResponder; DNS Cache was cleared successfully

If you’re using older macOS versions, the command you need to enter varies based on which version of macOS you’re running. For more details, you can refer to the macOS section in Kinsta’s in-depth flush DNS tutorial.

If you’re using the Linux operating system, then the process is quite similar to macOS as even Linux uses the Terminal as its command-line interface. Since there are many Linux distributions, the exact command you need to run may vary from one distro to another. You can check out Kinsta’s guide for more information.

Finally, you can change your client-side DNS servers temporarily. By default, your ISP assigns the DNS servers automatically to you. But you can change these to public DNS IPs temporarily.

Some reliable DNS servers you can try out are Google Public DNS, Cloudflare 1.1.1.1, Quad9 DNS, and Cisco OpenDNS.

Disable Your Site’s CDN Temporarily

Sometimes, the issue could also be with your content delivery network (CDN). If a site’s origin server isn’t reachable, most CDNs will try to serve the full webpage from their cache.

But most CDNs don’t enable this feature by default as it’s complex to cache dynamic assets on most sites (e.g. the WordPress admin dashboard).

A straightforward way to troubleshoot this is to disable your CDN temporarily. For example, if you’re using the free CDN Enabler WordPress plugin to link your site assets to the CDN URLs, then you can deactivate the plugin and test reloading your site.

The same goes for using any other plugin you may use to connect to your CDN (e.g. WP Rocket, Breeze, W3 Total Cache).

If you can’t access your site’s admin dashboard, you can disable the plugin via SFTP by renaming the plugin’s folder name.

CDNs like Cloudflare or Sucuri, which provide full proxy services, have extra firewalls between their edge servers and your origin server. Hence, you may encounter HTTP 5xx errors more frequently while using them. Most of them cache 5xx errors returned by your origin server, so it’s easy to troubleshoot them.

Cloudflare’s free plan is prone to throw up a 5xx error. Unfortunately, since it’s a full proxy service, there’s no quick way to disable it. But before you blame Cloudflare for it, know that Cloudflare shows two variations of the 504 Gateway Timeout error.

504 Gateway Timeout at Cloudflare (Variation 1)

Cloudflare will show you a custom 504 Gateway Timeout error screen when your site’s origin server responds with a standard HTTP 504 response.

Here, the issue lies with your web server and not Cloudflare. You can try fixing it with the other solutions mentioned below or contact your hosting provider’s support for technical help.

504 Gateway Timeout at Cloudflare (Variation 2)

If Cloudflare causes the 504 Gateway Timeout error, the error screen will mention “cloudflare,” which is currently the standard server name for all Cloudflare assets. Usually, the error screen will appear as below:

Since Cloudflare itself is unresponsive, you’ll not see any Cloudflare-branded error screen here.

Most likely, Cloudflare is already aware of the issue and is working on a fix already. You can confirm this by checking the Cloudflare System Status webpage. Alternatively, you can get in touch with Cloudflare support for a quicker resolution.

504 Gateway Timeout at Cloudflare Due to Large Uploads

The size of your uploads to your site can also be a reason for the server timeouts. Cloudflare limits upload file size (per HTTP POST request) to just 100 MB on both Free and Pro plans.

The issue can be on your host’s end or with Cloudflare. You can find out the exact cause by bypassing Cloudflare with your DNS hosts file and trying your upload again.

If you’re using Cloudflare with WordPress, I recommend using their free plugin and excluding critical URLs from caching (such as the WordPress admin dashboard). You can refer to Kinsta’s detailed post on how to configure Cloudflare settings for WordPress.

Suggested reading: How to Set up Cloudflare APO for WordPress.

Server Issues (Check With Your Host)

Server issues are one of the most common reasons for facing a 504 Gateway Timeout error. Since most WordPress sites are hosted on Nginx or Apache webservers, Nginx or Apache is waiting for a response from something and timing out.

Many clients come to Kinsta for exactly this problem they’re facing at other WordPress hosts. The conversation goes something like this:

Sign Up For the Newsletter Want to know how we increased our traffic over 1000%? Join 20,000+ others who get our weekly newsletter with insider WordPress tips! Subscribe Now

We’re getting around 100k visitors per month with more than 200k views. Currently, we’re hosting with ____ and we experience 504 errors constantly due to server overload. I don’t like how ____ handled the problem, and we were also advised that we will have to move to their dedicated plans soon, which I believe is not necessary.

High-traffic and ecommerce sites are more prone to getting 504 errors because of server overload as they generate many uncacheable requests. However, this issue can crop with any site, including simple blogs. Many hosts will ask you to upgrade to a high-tier plan to fix the issue, which in most cases is unnecessary.

Kinsta uses LXD managed hosts and orchestrated LXC software containers for each site. Thus, every WordPress site is housed in its own isolated container with access to all the software required to run it (Linux, Nginx, PHP, MySQL). The resources are 100% private and aren’t shared with any other site, even your sites.

Most WordPress hosts providing shared hosting plans don’t have this capability. Hence, a high-traffic site hosted on the same server as yours may cause your site to throw up a 504 error too.

Apart from isolating each site in its container, Kinsta has also designed its infrastructure to handle thousands of concurrent connections easily. Kinsta even hosts the MySQL databases at localhost, not a remote server. This means no latency between machines, resulting in faster queries and fewer chances of timeouts occurring.

Many clients who migrate to Kinsta see huge decreases in overall load times.

An overloaded server isn’t the only cause for a server timeout. There can be many other reasons for the 504 error:

Slow Server Infrastructure

The server you use to host your WordPress site may not have enough resources to handle the load. It’s like playing a modern, graphics-intensive videogame on a decade-old PC.

The server just hangs up trying to serve the website. The only solution to this problem is to upgrade to a server with better infrastructure. For this reason, even Kinsta’s most basic WordPress hosting plan will handle a static site with medium traffic.

Needs More PHP Workers

PHP workers are used to execute your WordPress site’s code. An ecommerce site that gets 50,000 visitors per month needs a lot more resources than a simple blog with the same amount of traffic. If all the server’s PHP workers are busy, they’ll build up a queue.

When the queue gets too big, the server disregards old requests, which may cause the server to throw up a 504 gateway error. You can ask your host about increasing your number of PHP workers. This’ll allow your site to execute multiple requests simultaneously.

Firewall Issues

Your server’s firewall could have some errors or an improper configuration. Perhaps, a few of its rules prevent the server from establishing a connection properly. To know if your firewall is the culprit, you can check your server’s error logs.

Network Connectivity Problems

Connectivity issues between the proxy server and the web server could cause delays in responding to HTTP requests. If you use a load balancer, there could also be network connectivity issues with it.

HTTP Timeouts

HTTP timeouts can occur when a connection between the web server and the client is kept open for too long. With WordPress sites, this usually happens when running WordPress imports. One way to resolve this issue is to switch to a faster internet connection.

You can also use a tool with support for WP-CLI to run the scripts directly on the server, bypassing the HTTP connection entirely. For instance, you can use the wp import WP-CLI command to run the WordPress Importer plugin directly through the command-line interface.

Important: 504 Gateway Timeout errors look similar to 503 Service Unavailable errors or 502 Bad Gateway errors. But they’re all different. If you’re experiencing a 504 error at Kinsta, open a support ticket to get your issue fixed immediately.

For monitoring your site’s downtime on your own, you can use a tool like updown.io. It’ll check your website’s status (or any URL) periodically by sending an HTTP request to it. You can set the check frequency from 15 seconds to 1 hour. If your website isn’t responding correctly, it’ll notify you with an email or an SMS.

You’ll get a generous quantity of free credits with every account of updown.io, but if you’re looking for cheaper alternatives, you can check out WebGazer or UptimeRobot. Both these tools will help you monitor your site’s uptime every 5 minutes for free. That’s decent enough for most website owners.

Monitoring your website will give you an idea of how often it’s down. This is especially helpful if you’re using a shared hosting provider. Most managed WordPress hosts take care of this automatically for you. Hence it’s always recommended to go with them.

For a detailed explanation, check out Kinsta’s post on the importance of managed WordPress hosting.

Spam, Bots, or DDoS Attacks

Malicious attackers can bring your web server to a crawl by sending too many and/or resource-intensive requests. If your site is getting spammed by bots or undergoing a DDoS attack, it can overwhelm your server and result in 504 Gateway Timeout errors for many genuine users.

You can look at your server traffic and analytics to see if you can spot any irregular patterns in the site traffic. If you’re using Kinsta to host your site, you can view this data easily by going to your MyKinsta Analytics dashboard.

Start your investigation by looking at the top client IPs. It’ll give you an idea of who generates the maximum number of requests, and from where. If your server suddenly uses up enormous bandwidth or attracts a lot of traffic, then this report will come in super handy.

Next, you can check out the Cache Analysis report. Here, you can see how many requests are bypassing or missing the cache, or being served from the cache. For performance and stability reasons, you want to cache as many requests as possible, but it’s not always possible to achieve that.

For example, WooCommerce sites generate many uncacheable requests for features such as the shopping cart and the checkout process.

Struggling with downtime and WordPress issues? Kinsta is the hosting solution designed with performance and security in mind! Check out our plans

Finally, you can use a WordPress security plugin to beef up your website’s security by spotting and blocking worrisome traffic/IPs. You can ask your host to block certain IPs too.

Depending upon the length and scale of the attack, this could be a never-ending process of blacklisting IPs as many attackers change their IPs and proxy addresses after getting blocked.

Note: Kinsta doesn’t allow its clients to install WordPress security plugins as they can have a huge effect on the site’s performance, especially its scanning capabilities. As Kinsta uses load balancers with Google Cloud Platform, blocking IPs wouldn’t always work as intended.

You can use dedicated security solutions such as Cloudflare or Sucuri to protect your sites from DDoS attacks and spambots. For more, you can check out Kinsta’s articles on how to install Cloudflare on your WordPress site and how Sucuri helped stop a DDoS attack in its tracks.

Corrupted WordPress Database

Sometimes, a 504 Gateway Timeout error can be because of a corrupt database, especially in WordPress sites. Typically, this is due to corrupted database tables or files. Sometimes, it can also be caused by a serious security issue like your site or database being hacked.

Repairing a corrupted WordPress database depends on the problem. Plugins like WP-DBManager make it easy to diagnose database issues and repair them. I recommend you to read Kinsta’s detailed walkthrough on repairing WordPress database issues to get started.

Check Your Site’s Plugins and Themes

In most cases, third-party plugins and themes don’t cause 504 errors. But there’s a slight chance that they might cause server timeouts, usually by queuing up many uncached requests generated by the plugin/theme. As this ties up a lot of your server’s PHP workers, it can cause 504 errors.

A great example of this issue is WooCommerce, a plugin installed to add ecommerce functionality to WordPress sites.

The simplest way you can troubleshoot this problem is by deactivating all your plugins. Remember, you won’t lose any data if you just deactivate a plugin.

If you can access your admin dashboard, you can go to the Plugins screen, select Deactivate from the bulk actions menu, checkmark all the plugins, and then hit the Apply button. This will disable all of your plugins.

If you can’t access your admin area, you can disable plugins via SFTP using the method described before. Just rename the main plugin folder name to disable all the plugins in bulk.

Once you’ve deactivated all the plugins, check whether your site loads properly. If it works, you must activate each plugin, testing the site after enabling every plugin.

Finally, make sure that your plugins, themes, and WordPress core are up to date. Also, ensure that your server is running the recommended version of PHP.

If you feel this to be too overwhelming, you can always reach out to your host for help. Kinsta uses Kinsta APM and other troubleshooting techniques to help clients narrow down what plugin, query, or script might cause the error.

In the worst-case scenarios, like an inefficient query or bad code in a plugin/theme, you can bring in a WordPress developer to fix the issue.

Check Error Logs

Viewing error logs can be very helpful when troubleshooting and debugging 504 errors on your WordPress site. This can help you narrow down an issue on your site quickly, especially if it’s resulting from a demanding plugin on your site.

If you’re a Kinsta customer, you can easily see errors in the log viewer in your MyKinsta dashboard.

If your host doesn’t have a logging tool, then you can enable WordPress debug mode by adding the following code to your wp-config.php file:

define( ‘WP_DEBUG’, true ); define( ‘WP_DEBUG_LOG’, true ); define( ‘WP_DEBUG_DISPLAY’, false );

The WP_DEBUG constant enables or disables the WordPress debug mode. It has two optional companion constants that can extend its features. The WP_DEBUG_LOG constant directs all errors to be saved to a debug.log file within the /wp-content/ directory. If you don’t see this file, you can always create one.

The WP_DEBUG_DISPLAY constant controls whether debug logs show up on the HTML page. Setting this to false will hide all errors, but you can review the errors later, as you’ve also defined WP_DEBUG_LOG as true.

Important: If you have WP_DEBUG enabled in the Kinsta environment, it’ll route all errors to the debug.log file and not the error.log in the MyKinsta dashboard.

You can also download the raw WordPress error log files via SFTP. Typically, you can find error logs in your server’s root directory in a folder named “logs.”

Kinsta users can also enable WordPress debug mode from their MyKinsta dashboard. To do that, navigate to Sites > Tools > WordPress Debugging and click the Enable button. This will allow you to see PHP errors and notices without enabling debug mode via SSH or SFTP.

Lastly, you can check the server log files. Depending on which server you’re using to host your WordPress site, they’re commonly found in these locations:

Apache: /var/log/apache2/error.log/

Nginx: /var/log/nginx/error.log/

You can refer to logging related documentation of Apache or Nginx for more information.

Configure Apache or Nginx Settings Properly

You can edit your server config files to increase resource limits for specific directives. This can help you resolve the 504 Gateway Timeout error.

For Apache Webservers

First, add the following code to your httpd.conf:

TimeOut 600

This setting defines how long the server will wait for certain requests before marking it as a network timeout issue. Its default value is 60 seconds (Apache 2.4 version).

You can only add this directive in your httpd.conf file, not in your .htaccess file. Since most shared hosting providers don’t allow you to modify the httpd.conf file, you can try increasing the value of the LimitRequestBody directive in your .htaccess file instead.

Then add the following line to your php.ini file:

max_execution_time 300

The default value of PHP’s max_execution_time directive is 30 seconds. Increasing it will allow your site’s PHP scripts to run longer.

For Nginx Webservers

If you’re running your WordPress sites on Nginx + FastCGI Process Manager (PHP-FPM) or using Nginx as a reverse proxy for Apache, you can tweak the server settings to help prevent 504 Gateway Timeout errors.

504 Gateway Timeout Error on Nginx + FastCGI (PHP-FPM)

First, you must edit your PHP-FPM pool config file. You can find it at the /etc/php7.4/fpm/pool.d/www.conf location in your Nginx server (the exact path may vary based on the PHP version). Alternately, you can run the following command in your terminal to edit the PHP-FPM pool config file:

sudo nano /etc/php/7.2/fpm/pool.d/www.conf

Next, set the following directive:

request_terminate_timeout = 300

After this, you must edit your php.ini file. You can locate it at /etc/php.ini . Open the file and add/change the value for the max_execution_time directive to 300 seconds.

max_execution_time = 300

Finally, add the following code to your nginx.conf file’s location block:

location ~ .php$ { … fastcgi_read_timeout 300; }

Reload Nginx and PHP-FPM for the changes to take effect.

sudo service nginx reload sudo service php7.4-fpm reload

The exact code to reload PHP-FPM will vary based on the PHP version installed on your server. Test your site to see whether it has fixed the issue.

504 Gateway Timeout Error on Nginx Proxy

If you’re using Nginx as a reverse proxy server for Apache, then you can make it more lenient towards server timeouts by adding the following directives to your nginx.conf file:

proxy_connect_timeout 600; proxy_send_timeout 600; proxy_read_timeout 600; send_timeout 600;

Don’t forget to reload Nginx after making your changes.

sudo service nginx reload

Other HTTP Errors Like 504 Gateway Timeout

As mentioned earlier in the article, many other HTTP 5xx errors are just like the 504 Gateway Timeout error. It’s because they all happen on the server-side. These errors include:

Other HTTP errors caused due to client-side issues, like the 404 Not Found error, are also like the 504 error. You can refer to Kinsta’s detailed guide and list of HTTP status codes for more information.

When you don’t know what caused a 504 Gateway Timeout error, how do you fix it in time to keep hard-earned visitors from bouncing to competitor sites? 🤷‍♂️ All the details are in this post. ⬆️

Click to Tweet

Summary

Your WordPress site can be affected by the 504 Gateway Timeout error because of multiple reasons. In this article, you learned how to troubleshoot them all. Typically, these errors are caused due to server-side issues, in which case you can reach out to your host and get it resolved quickly.

However, you must also understand that this error can be due to third-party plugins, themes, services, inefficient database queries, or a combination of two or more of these. If you’re maxing out your server’s resources (e.g. PHP workers), it’s recommended to optimize your site for performance.

If you still find that your website is timing out, then it might very well be that you need to upgrade your hosting plan or the number of PHP workers. I recommend you to consider this option only after you’ve exhausted all the other solutions described in this article.

From simple static sites to complex ecommerce and membership sites, Kinsta’s scalable hosting plans are designed to accommodate all types of websites. To learn more about our scalable cloud hosting, check out this article!

Did we miss anything? If you’re still finding it difficult to fix the 504 Gateway Timeout error on your WordPress site, leave a comment below.

Làm thế nào để sửa lỗi 504 gateway time-out trong WordPress

WordPress VPS Th1 24, 2020 Hai G. 5ít nhất Đọc

Làm thế nào để sửa lỗi 504 gateway time-out trong WordPress

Lỗi 504 gateway time-out là HTTP status codes mà server trả về khi server không nhận được phản hồi kịp thời từ server mà nó đang truy cập để cố tải trang web hoặc thực hiện một yêu cầu nào đó từ server.

Mặc dù nó ít xảy ra hơn lỗi 500 internal server error hay lỗi 502 bad gateway error. Mọi người ắt hẵn đã thấy lỗi này ít nhất vài lần khi truy cập trên Internet. Bài hướng dẫn này sẽ giải thích cho bạn biết 504 gateway time-out error là lỗi gì và làm thế nào để xử lý nó.

Lỗi 504 gateway time-out là gì?

HTTP status codes bắt đầu với số “5” là lỗi liên quan đến server. Lỗi này xuất hiện khi server không thể hoàn tất yêu cầu vì bị mất liên lạc khi thực hiện giao tiếp giữa các server với nhau. Khi bạn truy cập bất kỳ website nào, bạn sẽ gửi truy vấn tới website và các web servers sẽ xử lý truy vấn đó. Mỗi lần xử lý, server trả về HTTP status code với nội dung/tài nguyên được yêu cầu. Mặc định, HTTP status code sẽ không được hiển thị trừ khi có lỗi trong quá trình xử lý.

Như đã nói ở trên, 504 gateway time-out lỗi khi một server không nhận được phản hồi trong thời gian cho phép từ server gateway hay proxy khác.

Lỗi 504 gateway time-out cũng có nhiều dạng. Ví như bên dưới:

504 Gateway Timeout nginx

Gateway Timeout Error

HTTP Error 504

504 Gateway Time-out – The server didn’t respond in time

HTTP Error 504 – Gateway Timeout

Làm thế nào để sửa lỗi 504 gateway time-out

Mặc dù kể cả khi lỗi 504 thường do phía server, nhưng có một số lý do cũng do cấu hình sai từ phía client. Vì vậy, chúng tôi sẽ đi qua bài bước cơ bản để bạn có thể tự sửa lỗi được. Mặc dù chúng tôi chủ yếu sửa lỗi 504 trên WordPress nhưng bạn cũng có thể áp dụng cách tương tự với các website khác.

1. Tải lại trang

Bước đầu tiên để fix lỗi 504 gateway timeout rất đơn giản. Bạn chỉ cần chờ vài phút và tải lại trang / refresh website. Server trước đây có thể nhận nhiều request hơn bình thường nên không xử lý kịp request. Bạn có thể thử refresh ở thời điểm khác xem vấn nó có xử lý được không.

Trong thời gian chờ đợi, bạn cũng có thể dùng công cụ kiểm tra xem website có bị down hay không. Đây là một cách đơn giản để xác định lỗi có liên quan đến máy local hay không. Hình bên dưới là ví dụ website của bạn vẫn đang UP (hoạt động bình thường), nếu gặp tình trạng này thì bạn biết là do máy local chứ không phải do server.

2. Thử dùng browser khác

Nếu thấy website hoạt động (Up/Active), nhưng bạn vẫn thấy 504 gateway timeout, thử dùng một trình duyệt khác. Xóa cache hoặc mở incognito mode cũng có thể giúp bạn xử lý nếu lỗi liên quan đến browser đang dùng

3. Flush DNS

Lỗi 504 đôi khi cũng có thể do DNS cache bị lỗi thời hoặc sai. Không khó để xử lý khi gặp tình trạng này, vì bạn chỉ cần Flush DNS là được. Mặc dù cách xóa cache DNS có hơi khác trong các hệ điều hành khác nhau, nhưng đều rất dễ làm, bạn chỉ cần xem qua hướng dẫn flush DNS trên Windows, Linux, và MacOS một lần là làm được.

Tạm thời đổi DNS server thành Google Public DNS cũng có thể giúp bạn xử lý lỗi HTTP status code nếu vấn đề do DNS. Chúng tôi chỉ khuyên dùng cách này nếu bạn có kinh nghiệm về máy tính một chút.

4. Kiểm thử với thiết bị khác

Thử tải lại trang trên các thiết bị khác và trên đường mạng khác như sử dụng điện thoại để truy cập web bằng 4G. Trong trường hợp lỗi này không hiện lên trên điện thoại, bạn sẽ biết là vấn đề nằm ở máy tính của bạn thay vì tưởng là do server.

5. Kiểm tra Error Log

504 gateway time-out error cũng có thể xuất hiện do cập nhật hoặc website mới thay đổi. Cách dễ nhất là tìm trong error log. WordPress users có thể kích hoạt việc ghi lỗi bằng cách thêm các dòng sau vào file wp-config.php:

define( ‘WP_DEBUG’, true ); define( ‘WP_DEBUG_LOG’, true ); define( ‘WP_DEBUG_DISPLAY’, false );

Khi hoàn tất, các thông tin sẽ được lưu vào file wp-contents/debug.log.

6. Kiểm tra lại Plugins

Trong quá trình tìm cách sửa lỗi 504 gateway time-out, bạn nên chú ý tới plugins và extensions. Trong WordPress, plugin có khả năng cache cũng có thể gây ra tình trạng này. Plugin lỗi thời hoặc không tương thích cũng có thể gây lỗi. Vì vậy, vô hiệu toàn bộ plugin sẽ cho bạn biết lỗi có liên quan đến plugin hay không.

Cách vô hiệu plugin WordPress rất đơn giản, chỉ cần chuyển tới thư mục wp-content và đặt tên folder plugins thành tên khác, ví dụ như plugins.disable.

Nếu site của bạn chạy lại thì lỗi dĩ nhiên liên quan đến plugin. Bước tiếp theo bạn cần xác định chính xác plugin nào gây lỗi HTTP error 504. Đổi tên plugins.disable ngược lại thành plugins và thử vô hiệu tuần tự từng plugins.

7. Kiểm tra CDNs

Nếu bạn đang dùng CDN để tăng tốc nội dung, bạn có thể thử kiểm tra lại xem mọi thứ ổn không từ CDN của bạn. Một trong số các lý do thường thấy là do CloudFlare, hoạt động như là một CDN và dịch giảm tấn công DDoS. Trong quá trình sử dụng, bạn có thể gặp 2 phiên bản 504 gateway time-out như sau:

Phiên bản lỗi 504 là do phía CloudFlare. Cách tốt nhất là liên hệ với bên CloudFlare để được hỗ trợ hoặc tạm thời vô hiệu nó hoàn toàn. Tuy nhiên, nếu bạn vô hiệu nó, bạn có thể phải chờ vài giờ để DNS được quảng bá.

Phiên bản bên dưới là do liên quan đến nhà cung cấp web hosting. Nếu gặp tình trạng này bạn hãy tiếp tục thực hiện bước tiếp theo

8. Điều chỉnh cấu hình Server

Nếu bạn đang dùng VPS hosting, có một số cách khác để sửa lỗi 504 gateway time-out: tăng thời gian time-out trên server và nâng tài nguyên lên.

Sửa lỗi 504 gateway time-out Apache

Apache users có thể tăng thời gian timeout mặc định lên trong file httpd.conf file. Ví dụ:

# Timeout: The number of seconds before receives and sends time out. Timeout 600

Hơn nữa, hãy tăng thêm giới hạn max_execution_time trong file php.ini:

max_execution_time 300

Lưu lại thay đổi, khởi động apache và kiểm tra lại. 504 gateway timeout error sẽ biến mất nếu nguyên do là không đủ tài nguyên hoặc thời gian để xử lý.

Sửa lỗi 504 gateway time-out Nginx

504 gateway timeout Nginx xảy ra do nhiều nguyên do liên quan đến việc phân phối nội dung phía backend. Thường do server hoạt động dưới dạng gateway hoặc proxy không đủ thời gian nhận phản hồi từ upstream server.

Vậy trên VPS Nginx, hãy thử tăng giới hạn time-out trong file /etc/nginx/conf.d/timeout.conf:

proxy_connect_timeout 600; proxy_send_timeout 600; proxy_read_timeout 600; send_timeout 600;

Chúng tôi cũng khuyên tăng giới hạn max_execution_time trong php.ini:

max_execution_time 300

Khi lưu xong thay đổi, hãy khởi động lại Nginx và thử truy cập website lần nữa. Bạn sẽ thấy lỗi 504 gateway time-out Nginx đã được sửa.

Cuối cùng, 504 gateway time-out vẫn còn xuất hiện trên website của bạn sau khi đã thử toàn bộ các cách ở trên, chúng tôi khuyên là hãy liên hệ với nhà cung cấp hosting của bạn. Thử mô tả toàn bộ chi tiết quá trình bạn sửa lỗi và cung cấp nhiều thông tin cần thiết để nhân viên chúng tôi sửa nhanh hơn cho bạn.

Lời kết

Trong bài hướng dẫn này, chúng tôi đã chỉ bạn một số bước cơ bản để sửa lỗi 504 gateway time-out. Nếu bạn có bất kỳ thủ thuật nào khác để sửa lỗi, một số mẹo nào khác, hãy để lại bình luận bên dưới nhé!

504 Gateway Timeout NGinx

I am running into a 504 gateway timeout error with my express API. I have a droplet using docker-compose to spin up all the resources. When doing research into the issue people say usually you run out of ram but my memory is only at 60%. I think this is more of a load balancer issue but am unaware of the steps to proceed. I added the client_header_timeout config to nginx.config but that didn’t solve the issue. Any insights would be appreciated.

키워드에 대한 정보 nginx 504

다음은 Bing에서 nginx 504 주제에 대한 검색 결과입니다. 필요한 경우 더 읽을 수 있습니다.

이 기사는 인터넷의 다양한 출처에서 편집되었습니다. 이 기사가 유용했기를 바랍니다. 이 기사가 유용하다고 생각되면 공유하십시오. 매우 감사합니다!

사람들이 주제에 대해 자주 검색하는 키워드 Nginx Bad Gateway 504

  • Nginx Bad Gateway timeout
  • 504 Bad Gateway
  • Nginx 504 Bad Gateway

Nginx #Bad #Gateway #504


YouTube에서 nginx 504 주제의 다른 동영상 보기

주제에 대한 기사를 시청해 주셔서 감사합니다 Nginx Bad Gateway 504 | nginx 504, 이 기사가 유용하다고 생각되면 공유하십시오, 매우 감사합니다.

See also  대리 운전 알바 후기 | 초보 대리운전 딱 3시간만 하면 얼마나 벌까요..??(수익금 공개)직접 경험 해 본 대리운전 알바 브이로그 인기 답변 업데이트

Leave a Reply

Your email address will not be published. Required fields are marked *