---
slug: "ingress-uwsgi-timeout-threshold"
title: "Items to Check to Prevent Timeout for Slow Responses in Kubernetes Ingress + Uwsgi Configuration"
description: "Checklist of timeout settings (Ingress, uWSGI, Django, nginx) to verify so slow responses don't get cut off in a Kubernetes + uWSGI stack."
url: "https://www.ytyng.com/en/blog/ingress-uwsgi-timeout-threshold"
publish_date: "2022-08-19T10:51:48Z"
created: "2022-08-19T10:51:48Z"
updated: "2026-05-11T13:13:04.686Z"
categories: ["kubernetes"]
keywords: ""
featured_image_url: "https://media.ytyng.com/resize/20230812/9f6112f3ea594ef1bcef3cbcc1a9888a.png.webp?width=768"
has_video: false
has_music: false
video_urls: []
music_urls: []
lang: "en"
---

# Items to Check to Prevent Timeout for Slow Responses in Kubernetes Ingress + Uwsgi Configuration

<p>When using an Nginx Ingress Controller in Kubernetes and having an application server in the Pod that uses Uwsgi, here are some points to check to prevent services with slow response times from timing out.</p>
<p>If you don't extend these settings, you may encounter 502 or 504 errors.</p>
<p></p>
<h2>1. Ingress</h2>
<pre>apiVersion: networking.k8s.io/v1<br />kind: Ingress<br />metadata:<br />  name: my-app<br />  namespace: my-namespace<br />  annotations:<br />    nginx.ingress.kubernetes.io/proxy-connect-timeout: '900'<br />    nginx.ingress.kubernetes.io/proxy-send-timeout: '900'<br />    nginx.ingress.kubernetes.io/proxy-read-timeout: '900'</pre>
<p></p>
<h2>2. uwsgi.ini</h2>
<pre>[uwsgi]<br />...<br />socket-timeout = 600<br />http-timeout = 600<br />harakiri = 600</pre>
<p></p>
<h2>Measurement View</h2>
<pre>import time<br />from django import http<br />from django.views import View<br /><br /><br />class DevSleepView(View):<br />    """<br />    A view that sleeps for a long time. Used to check for timeouts<br />    /dev/sleep/?seconds=60<br />    """<br /><br />    def get(self, request, *args, **kwargs):<br />        sleep_time = int(request.GET.get('seconds', 30))<br />        start = timezone.now()<br />        time.sleep(sleep_time)<br />        end = timezone.now()<br />        return http.HttpResponse('{} - {}, Slept {}seconds.'.format(<br />            start.strftime('%Y-%m-%d %H:%M:%S'),<br />            end.strftime('%H:%M:%S'),<br />            sleep_time))</pre>
