Web Application Request Timeout Settings

Web Servers


Error Information

Status Code: 504


<head><title>504 Gateway Time-out</title></head>
<body bgcolor="white">
<center><h1>504 Gateway Time-out</h1></center>

Default Timeout

The default timeout for Nginx is 60 seconds.


Update proxy timeout to 180 seconds:

http {
proxy_connect_timeout 180s;
proxy_send_timeout 180s;
proxy_read_timeout 180s;

Java HTTP Client

Spring RestTemplate

Default Timeout

The default timeout is infinite.

By default RestTemplate uses SimpleClientHttpRequestFactory and that in turn uses HttpURLConnection.

By default the timeout for HttpURLConnection is 0 - ie infinite, unless it has been set by these properties :



public RestTemplate restTemplate() {
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
// Time to establish a connection to the server from the client-side. Set to 20s.
// Time to finish reading data from the socket. Set to 300s.
return new RestTemplate(factory);

JavaScript HTTP Client


Default Timeout

The default timeout is 0 (no timeout).


const instance = axios.create({
baseURL: 'https://some-domain.com/api/',
// `timeout` specifies the number of milliseconds before the request times out.
// If the request takes longer than `timeout`, the request will be aborted.
timeout: 60000,