Prevent Long Running Node Script Timeout

To prevent long running node script running under nginx from timing out need to set setting in two places.

1) Modify /etc/nginx/nginx.conf. Add these lines in the location block.

proxy_connect_timeout 60;
proxy_read_timeout 3600;

2) In node application app.js file where server listener setup.

var server = app.listen(serverPort);
server.timeout = 3600000; // 1 hour in milliseconds

3) Restart nginx

sudo /etc/init.d/nginx restart

Leave a comment

0 Comments.