502 Bad Gateway Django

I have a simple application that allows you to upload images to a server and is configured on my production server, which consists of django + uwsgi + ngnix.

I have a problem loading an image. I get the following error:

Error

502 Bad Gateway nginx/1.2.1 

function:

 def upload(request): form = ImageForm() context = {'form':form,} context.update(csrf(request)) if request.POST: form = ImageForm(request.POST, request.FILES) if form_is.valid(): image = request.FILES.get('image') CarPhoto.objects.create(user=request.user,cars=1,description='dwq',image=image) return HttpResponseRedirect(reverse('transformer:kevin')) return render_to_response('image.html',context,context_instance=RequestContext(request)) 

template

  <form method="POST" enctype="multipart/form-data" action="."> {% csrf_token %} <div id="c">image</div> {{form.image}} <input type = "submit" value= "add" id="box2"/> </form> 

mysite.com_error.log

  "uwsgi://unix:///tmp/mysite.com.sock:", host: "174.414.14.551", referrer: "http://174.414.14.551/car/upload" 2013/06/26 12:07:39 [error] 28870#0: *5 sendfile() failed (32: Broken pipe) while sending request to upstream, client: 313.19.220.424, server: mysite.com, request: "POST /car/ HTTP/1.1", upstream: "uwsgi://unix:///tmp/mysite.com.sock:", host: "174.414.14.551", referrer: "http://174.414.14.551/car/upload" 2013/06/26 12:08:12 [error] 29065#0: *5 sendfile() failed (32: Broken pipe) while sending request to upstream, client: 313.19.220.424, server: mysite.com, request: "POST /car/ HTTP/1.1", upstream: "uwsgi://unix:///tmp/mysite.com.sock:", host: "174.414.14.551", referrer: "http://174.414.14.551/car/upload" 2013/06/26 12:08:18 [error] 29065#0: *7 readv() failed (104: Connection reset by peer) while reading upstream, client: 313.19.220.424, server: mysite.com, request: "POST /car/ HTTP/1.1", upstream: "uwsgi://unix:///tmp/mysite.com.sock:", host: "174.414.14.551", referrer: "http://174.414.14.551/car/upload" 2013/06/26 12:09:11 [error] 29065#0: *9 readv() failed (104: Connection reset by peer) while reading upstream, client: 313.19.220.424, server: mysite.com, request: "POST /car/ HTTP/1.1", upstream: "uwsgi://unix:///tmp/mysite.com.sock:", host: "174.414.14.551", referrer: "http://174.414.14.551/car/upload" 2013/06/26 12:09:52 [error] 29065#0: *14 sendfile() failed (32: Broken pipe) while sending request to upstream, client: 313.19.220.424, server: mysite.com, request: "POST /car/ HTTP/1.1", upstream: "uwsgi://unix:///tmp/mysite.com.sock:", host: "174.414.14.551", referrer: "http://174.414.14.551/car/upload" 2013/06/26 12:10:51 [error] 29065#0: *19 sendfile() failed (32: Broken pipe) while sending request to upstream, client: 313.19.220.424, server: mysite.com, request: "POST /car/ HTTP/1.1", upstream: "uwsgi://unix:///tmp/mysite.com.sock:", host: "174.414.14.551", referrer: "http://174.414.14.551/car/upload" 
+4
source share
2 answers

It looks like your uWSGI instance has died or is not working in such a way that it does not know how to respond.

Start by looking at nginx logs in addition to uWSGI logs and see how far it goes.

Perhaps the file you are loading is so large that it suffocates part of the front stream.

Edit the message to indicate the output of the two log files, and we will see.

+1
source

If a third-party application is included in your project, it must also be installed on your server, as well as a south-sided application. Consider the south included in your settings.py file, and then the south should also be installed on your server. If this module considers the south here, it is already installed on the server, and then try updating it. Since it is possible that you are using the updated version of the module on the local computer, and an older version is installed on the server.

+1
source

Source: https://habr.com/ru/post/1488285/


All Articles