JAVA development (remember a 504 gateway timeout error troubleshooting process)

1. Problem and background:

Recently, I am releasing a web project, which is available in the test environment, and it is also possible to publish it to the production environment through IP access, but 504 gateway timeout occurs when accessing through the domain name. The same is true for testing interfaces through postman. Both ip and port can be communicated, but the domain name is not, which is puzzling. Through a Baidu search, it is analyzed that these places are configured through the nginx configuration file

  fastcgi_connect_timeout 300;
  fastcgi_send_timeout 300;
  fastcgi_read_timeout 300;
  fastcgi_buffer_size 256k;
  fastcgi_buffers 2 256k;
  fastcgi_busy_buffers_size 256k;
  fastcgi_temp_file_write_size 256k;

The result has no effect, but it should be possible in some scenarios. For example, accessing through IP also reports a 504 error, but it is not my scenario.

Then continue to have instructions to say that by configuring in the server

  proxy_connect_timeout    6000;  #nginx跟后端服务器连接超时时间(代理连接超时)默认60s
  proxy_read_timeout       6000; #后端服务器数据回传时间(代理发送超时)默认值60s
  proxy_send_timeout       6000;  #连接成功后,后端服务器响应时间(代理接收超时)默认值60s

 Then it didn't work either.

There should be some scenarios that should be possible. For example, accessing through IP also reports a 504 error, but it is not my scenario.

The above two schemes should be the two schemes currently available on the Internet. But it didn't solve my problem.

Then we have to understand the 504 error scenario from scratch. Maybe it's not entirely caused by the web server being unresponsive.

Second, the definition and analysis of 504 errors:

The 504 error represents Gateway timeout, which means that the server acts as a gateway or proxy, but does not receive the request from the upstream server in time.

The server (not necessarily a web server) is acting as a gateway or proxy to fulfill requests from clients (such as your browser or our CheckUpDown robot) to access the desired URL. In order to fulfill your HTTP request, the server reached out to an upstream server, but did not get a timely response.

This usually means that the upstream server is down (not responding to the gateway  /proxy), not that the upstream server and gateway/proxy disagree on the protocol for exchanging data.

Under normal circumstances, it is caused by the timeout sent by the requested server.

3. The principle of 504 error:

Used by a server acting as a proxy or gateway to indicate that a reply from the remote server could not be obtained in a timely manner    .

When any client communicates with a web server , it needs to go through the following cycle:

Obtain an IP address from the site's IP name (ie the site's web address - URL, without the initial 'http://')   . This correspondence (that is, the translation from IP names to IP addresses) is provided by Domain Name Servers (DNSs).

Open an IP  socket  (socket) to connect to this IP address.

Write HTTP data streams through this socket.

The HTTP data stream that receives the response from the web server. This data stream includes a status code whose value depends on the HTTP protocol. Parsing the data stream yields status codes and other useful information.

This error is generated in the last step described above, when the client receives the HTTP status code and recognizes it as '504'.

This problem is purely caused by slow IP communication between the backend computers, possibly including the web server. If the web server is hosted by a website, only the person responsible for that website's settings can fix this problem.

The use of proxies and caches on the web is increasing day by day. While the CheckUpDown bot will always try to 'drill into' the computer that actually hosts your website, you don't have full control over where the HTTP request actually lands. As long as one link in the chain of computers processing HTTP requests is broken, errors like 504 can easily occur.

4. The ip can access the domain name and report a 504 error. The final solution:

Then it may be that the domain name resolution environment is added to the firewall link, and errors may also result in 504. As a result, after investigation, it was found that the domain name resolution corresponding port configuration error caused 504. Later, the policy was modified, and the problem was finally solved.

5. The 504 error may also be the following scenarios:

1. Computer browser error: This error occurs when there is some error in the browser configuration or settings

2. DNS errors: Improper configuration of domain DNS may cause errors when browsing domains

3. Unstable network: Poor data connection between proxy and web server may lead to delayed response

4. Slow web server speed: low web server features may cause gateway ip request timeout

5. The main reason for the 504 error is a firewall configuration error: the firewall rules are incorrect

504 Gateway how to solve timeout

1. Refresh the page

The first step in dealing with a 504 Gateway timeout error is to hit the update/reload button, press F5 or try searching for the URL from the search box again, then try the web page. may be the server

At that time, I received more requests than usual, and many requests could not be resolved, resulting in a short 504 Gateway Timeout.

2. Restart various devices

A temporary problem with your modem, wireless router, network switch, or other network hardware is likely to cause the 504 Gateway Timeout you're seeing. Trying to reboot this device might help everyone.

3. Check the proxy server settings

Use a browser or program to check the proxy server settings to make sure they are correct and accurate. Incorrect network settings are likely to cause 504 Gateway timeout errors.

4. Change DNS server

Change DNS servers, especially if various devices on the Internet experience the same error. The 504 Gateway Timeout error you are seeing is most likely due to a problem with the DNS server you are using.

5. Fix wrong firewall configuration

The firewall is the guardian of the page. It protects your website from intentional visitors. However, the network firewall in your server might encounter some bug, incorrect device or proper criteria blocking the connection, which will result in 504 Gateway timeout error.

6. Contact your server service provider

In some cases, try contacting your server service provider. This problem can be found more efficiently.

7. Try browsing this site later

If nothing else is successful, your last resort is to try browsing the site a bit.

Guess you like

Origin blog.csdn.net/dongjing991/article/details/131421783