Doing timeout properly for NGINX

tech kamar
Aug 19, 2024

I develop micro services for a living. All my microservices are sitting behind the NGINX server which acts as load balancer.

So anytime my micro service takes more than 120 seconds to respond. it used to timeout at NGINX level.

This is how I solved it.

Open /etc/nginx/nginx.conf file

Under the http section add these lines based on how many seconds you want to wait. I want to wait max of 120 seconds

http{
proxy_connect_timeout 120s;
proxy_send_timeout 120s;
proxy_read_timeout 120s;
send_timeout 120s;
}

Now reload the Nginx service

sudo systemctl reload nginx

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response