Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

457
Views
Failed to load resource: the server responded with a status of 504 (Gateway Timeout)

I am developing a project using django - python, javascript. When I call a long running process (time-consuming) approx more than 20 minutes from views the process starts successfully. I used loader in ajax to notify user that process is running. After the process completes the loader will stop and change to completed state.

But the issue is every time after 14.59 minutes from process started, the loader stops and status change to completed. But the process running in background is not yet completed. The page crash after that time. After the process complete I bind the result under a tag in web page. In that tag the error 504 (Gateway Timeout) arise. In web console log Failed to load resource: the server responded with a status of 504 (Gateway Timeout), the above error prints. If anyone knows please help me to fix this.

Is the django is closing the connection after that time ? If so is there possible to mention timeout in django settings (settings.py). I tried giving timeout in ajax call but the same issue returns. My doubt is on django development server. Is there timeout in django development server. But when I search for this issue I found, in nginx server the same type of issue arise. Is django depend on nginx or using it ?

I tried to provide all information regarding my issue if any further clarifications, please let me know.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The server always closes its connection after a particular amount of time, which can be modified by changing its configuration, but that would not be a good approach. I would suggest you to try to reduce time taken by the script by:

  • Optimizing Your code.
  • By caching data which is to be used often
  • using backend services which will process your data and store them in temporary storage such as memcache or redis which can be quickly accessed.

Also you should handle the timeout of the ajax call:

$.ajax({
    ...
    timeout: 1000,
    error: function(jqXHR, textStatus, errorThrown) {
        if(textStatus==="timeout") {
           //do something on timeout / show appropriate message.
        } 
    }
});​

References for tweaking performance and optimizing coding techniques thus reducing time: https://docs.djangoproject.com/en/1.10/topics/db/optimization/ https://docs.djangoproject.com/en/1.10/topics/performance/ https://realpython.com/blog/python/caching-in-django-with-redis/

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!