Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django can't access Azure mounted storage
I am running my Djagno app (python 2.7, django 1.11) on an Azure server using AKS (kubernetes). I have a persistent storage volume mounted at /data/media . When I try to upload files through my app, I get the following error: Exception Value: [Errno 13] Permission denied: '/data/media/uploads/<some_dir>' Exception Location: /usr/local/lib/python2.7/os.py in makedirs, line 157 The problematic line in os.py is the one trying to create a directory mkdir(name, mode) . When I use kubectl exec -it <my-pod> bash to access the pod (user is root), I can easily cd into the /data/media directory, create sub-folders and see them reflected in the Azure portal. So my mount is perfectly fine. I tried chmoding /data/media but that does not work. It seems like I cannot change the permissions of the folders on the mounted persistent volume, nor can I add users or change groups. So, it seems there is no problem accessing the volume from my pod, but since Django is not running as root, it cannot access it. Ho do I resolve this? Thanks. -
Inserting multiple values in django database - raw sqlite statements
I use the raw sql in django.. p.execute('''INSERT INTO webapp_information VALUES(login=%s, idd=%s, avatar_url=%s, gravatar_id=%s, url=%s, html_url=%s, followers_url=%s, following_url=%s, gists_url=%s, starred_url=%s, subscriptions_url=%s, organizations_url=%s, repos_url=%s, events_url=%s, received_events_url=%s,typ=%s,site_admin=%s, name=%s, company=%s, blog=%s, location=%s,email=%s, hireable=%s, bio=%s, public_repos=%s, public_gists=%s, followers=%s, following=%s, created_at=%s, updated_at=%s, dat=%s''',i) i is the list of values follow the custom sql fiven in the documentation https://docs.djangoproject.com/en/2.1/topics/db/sql/ /usr/local/lib/python2.7/dist-packages/django/db/backends/utils.pyc in execute(self, sql, params) 77 start = time() 78 try: ---> 79 return super(CursorDebugWrapper, self).execute(sql, params) 80 finally: 81 stop = time() /usr/local/lib/python2.7/dist-packages/django/db/backends/utils.pyc in execute(self, sql, params) 62 return self.cursor.execute(sql) 63 else: --> 64 return self.cursor.execute(sql, params) 65 66 def executemany(self, sql, param_list): /usr/local/lib/python2.7/dist-packages/django/db/utils.pyc in __exit__(self, exc_type, exc_value, traceback) 92 if dj_exc_type not in (DataError, IntegrityError): 93 self.wrapper.errors_occurred = True ---> 94 six.reraise(dj_exc_type, dj_exc_value, traceback) 95 96 def __call__(self, func): /usr/local/lib/python2.7/dist-packages/django/db/backends/utils.pyc in execute(self, sql, params) 62 return self.cursor.execute(sql) 63 else: ---> 64 return self.cursor.execute(sql, params) 65 66 def executemany(self, sql, param_list): /usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/base.pyc in execute(self, query, params) 335 return Database.Cursor.execute(self, query) 336 query = self.convert_query(query) --> 337 return Database.Cursor.execute(self, query, params) 338 339 def executemany(self, query, param_list): OperationalError: near "?": syntax error i never used the '?' where the django asked to use '%s' what to do.. thanks -
Force django admin search bar to be case insensitive
My problem is that for one of my models, the search bar from the corresponding admin page is performing a case sensitive search when it should be a case insensitive search by default. From what I could find here, I feel like this might have something to do with database encoding but from the doc, it says that Django assumes that everything is UTF-8 encoded and I checked my MySQL table and the fields are encoded in UTF-8. Could it be due to the presence of Greek characters in one of my field? How can I force a case insensitive search in at least the fields that don't contain Greek letters? Currently, the search is case sensitive for all the fields. But it works correctly (case insensitive) for other models. Model: class MyModel(models.Model): id = models.AutoField(primary_key=True) field1 = models.CharField(max_length=200, unique=True) # Might contain greek letters field2 = models.CharField(max_length=200, unique=True) Not sharing the admin class code as nothing fancy is in here. Just standard combination of list_display, search_fields, ordering and fieldsets. Using Django 1.10 -
How to run Django app from docker containers with rabbitmq
I have a django app which I want to run it locally and see the changes that I make simultaneously on the localhost rather that deploying it every time to the production server. My previous developers have put these on read me, I tried these steps but not able to launch it locally. docker run --rm --name postgres -e POSTGRES_PASSWORD=password -p 5432:5432 - v pgdata:/var/lib/postgresql/data -d postgres:9.6.2 docker run --name redis -d -p 6379:6379 redis docker run --rm -d --hostname my-rabbit --name rabbitmq -p 5671:5671 -p 5672:5672 -p 4369:4369 -p 25672:25672 rabbitmq:3 docker exec -it rabbitmq bash rabbitmqctl add_user wee wee rabbitmqctl add_vhost wee rabbitmqctl set_permissions -p wee wee ".*" ".*" ".*" -
Django __str__ returned non-string (type NoneType) but from django/contrib/admin
Hey sorry if that questions has been asked before but i havent found a fix yet looking at the previous questions. i am trying to use django-booking (https://github.com/bitlabstudio/django-booking/tree/master/booking) on my website/app, now i can do the booking as a client and save it, but in the admin side if i click on bookings, i get and error > TypeError at /admin/booking/booking/ > > __str__ returned non-string (type NoneType) > > Request Method: GET Request URL: > http://127.0.0.1:8000/admin/booking/booking/ Django Version: 2.0.8 > Exception Type: TypeError Exception Value: > > __str__ returned non-string (type NoneType) > > Exception Location: C:\Program > Files\Python37\lib\site-packages\django\contrib\admin\templatetags\admin_list.py > in items_for_result, line 235 Python Executable: C:\Program > Files\Python37\python.exe Python Version: 3.7.0 Python Path: > > ['C:\\Users\\Agustin Landivar\\Desktop\\Marie\\drLandivar', > 'C:\\Program Files\\Python37\\python37.zip', 'C:\\Program > Files\\Python37\\DLLs', 'C:\\Program Files\\Python37\\lib', > 'C:\\Program Files\\Python37', 'C:\\Program > Files\\Python37\\lib\\site-packages'] > > Server time: Tue, 21 Aug 2018 15:20:18 +0000 Error during template > rendering > > In template C:\Program > Files\Python37\lib\site-packages\django\contrib\admin\templates\admin\base.html, > error at line 70 how can i fix that to be able to see all the bookings in the admin without getting this error, i see that normally this error is because of a str, but its also says that the error is in … -
DateField issues in Django
I am struggling with some DateTime issues in Django. I believe it all comes down to data types and conversions and I am just not quite getting it. I would greatly appreciate if someone could clean up my code, as posted below. I would ask also not to change too much. I am very new to programming. I'm certain that there are better ways to accomplish what I am trying to do, but my understanding is limited to doing things a certain way. So if you could help me make this work without wholesale changes I would really appreciate it. Okay... As a learning project I am building a very basic "Travel App" in Django (Python 2, Django 1). I want users to be able to enter a start and end date for a trip. The start date must be in the future and the end date must be after the start date. First, I create my Trip table in models: class Trip(models.Model): destination = models.CharField(max_length=55) description = models.TextField() start_date = models.DateField(null=True) end_date = models.DateField(null=True) travelers = models.ManyToManyField(User, related_name="trips") planned_by = models.ForeignKey(User, on_delete=models.CASCADE, related_name="trips_added") created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) objects = TripManager() I think all is well with this. … -
Django template context variables don't show
I have a custom article.html template that is overriding the default article.html template that comes with the aldryn newsblog plugin. In this template I have 2 lines to include some custom functionality: {% include 'comment_form.html' %} {% include 'list_comments.html' %} Here are those 2 template files in detail: list_comments.html template: {% load cms_tags staticfiles sekizai_tags %} {% if comments %} {% for item in comments %} <div class="comment paragraph"> <h4>{{ item.author }}</h4> <p>{{ item.comment }}</p> <p>{{ item.date }}</p> </div> {% endfor %} {% else %} <p>No comments exist on this blog. Be the first to comment!</p> {% endif %} {{ another }} {{ thisdoesntexist }} and comment_form.html {% load cms_tags staticfiles sekizai_tags %} <div id="comment_form"> <div class="container constrained paragraph"> <h5>Submit a comment</h5> <form method="post"> {% csrf_token %} {{ comment_form }} <input type="hidden" name="page" value="{{ article.id }}"> <input type="submit" value="Submit Comment"> </form> </div> And views.py I have 2 functions to return views with context variables: def display_form(request): comment_form = CommentForm() return render(request, 'comment_form.html', {'comment_form': comment_form}) def get_blog_comments(request): qs = BlogComment.objects.all() context = {'comments': qs, 'another': 'TEST STRING'} return render(request, 'list_comments.html', context) And in both templates, the context variables are outputting nothing. I am at a loss for what I'm doing wrong. … -
Add Django FormWizard to a DetailView
I've been racking my brain on how to add FormWizard view say a subclass of NamedUrlSessionWizardView to a Detail view. As the detail view object is one of the fields of the first form, meaning it's a foreignkey. I know I can do FormRandomWizardView.as_view([Form1, Form2, Form3]), which makes it callable. My main issues are the following: 1.) Make the selected object pre-selected by it's id or slug on the first form of the formwizard, which means passing it as initial data on first form, 2.) Dealing with named url since NamedUrlSessionWizardView uses different templates. Here are sample codes below: class Service(models.Model): title = models.CharField(max_length=250) slug = models.SlugField(blank=True, unique=True) price = model.DecimalField(decimal_places=2) ...... other fields class Appointment(models.Model): service = models.ForeignKey(Service, on_delete=models.CASCADE) date = models.DateField() time = models.TimeField() ...... other fields Forms class AptForm1(forms.ModelForm): class Meta: model = Appointment fields = ['service', ....otherfields ] class AptForm2(forms.ModelForm): class Meta: model = Appointment fields = ['date', 'time', ...otherfields ] views class FormAptWizardView(NamedUrlSessionWizardView): templates = { 'service': 'appointment/booking_start.html', 'date_time': 'appointment/booking_date.html', 'confirm': 'appointments/booking_confirm.html', } .... whole lot of other logic formaptwizard = FormAptWizardView.as_view([('service', AptForm1), ('date_time', AptForm2), ...some other forms], url_name='appt:booking_step', done_step_name='finished') class ServiceDetail(FormMixin, DetailView): model = Service template = 'appointment/service.html' form_class = formaptwizard My dilemma starts … -
Preventing media folder in Django from being overwritten with new update
I have a Django model which includes an Image Field, and an app which consumes the model instance including all images. The problem I'm having now is while my data and the img local link resides on my AWS RDS database, the media folder which contains the images for the model is not. Thus every time I deploy a new version of the app (I'm using Beanstalk for deployment), my media folder is wiped clean and all my image link dies as a result. Below is my model: class Item(models.Model): # Fields name = models.CharField(max_length=30, help_text="Enter item name") description = models.TextField(help_text='Enter a short description') image = models.ImageField(help_text='Upload item image', upload_to='image/item/', default='image/demo.jpg') # Methods def __str__(self): return str(self.name) def get_absolute_url(self): return reverse('model-detail-view', args=[str(self.id)]) And I use serve to retrieve the image from Django. url(r'^resource/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT}), Now what would be the best way to resolve this problem? I would not want to upload the image to another server then link back to Django, it's best if I can save it to my database the moment I upload the file from my model form. All feedback is appreciated. -
Django: how to re-create correct migrations for existing database?
I have existing database and no migrations files (which was lost for some reasons). I have some new models, which are not correspond to existing database, some tables are altered in comparison with existing database. I'd like to synchronize db and models, means alter some tables in existing database. I have try this: Django 1.8: Create initial migrations for existing schema but when run manage migrate --fake-initial (or --fake) my first migration (created from new models) are marked as FAKED, so, if I got it well, fully ignored, so no tables are altered. Are there any way to automatically synchronize db and models (w/o exporting/importing data from/to db)? Somehow make initial migration as snapshot of existing database and then make migrations, relative to it? -
Editing wsgi.py does not fix error, ImportError: No module named django.core.wsgi
I have the same problem as here: ImportError: No module named django.core.wsgi Apache + VirtualEnv + AWS + WSGI but the solution is not working for me. I actually copied the more refined example offered here: https://pseudoscripter.wordpress.com/2015/10/23/import-error-no-module-named-django-core-wsgi/ I completely messed up on the previous EC2 instance, so I decided to create a new EC2 instance and start over. Some commands I ran to setup the server: yum upgrade -y yum update -y yum search python3 | grep devel yum install python3-pip.noarch -y yum install emacs -y yum install make automake gcc gcc-c++ kernel-devel -y yum install git -y yum install nginx -y yum install postgresql-devel -y yum install libtiff-devel libjpeg-devel libzip-devel freetype-devel lcms2-devel libwebp-devel tcl-devel libxslt-devel libxml2-devel -y yum install openssl-devel -y yum install python-virtualenv.noarch amazon-linux-extras install nginx1.12 Then I did some work setting up Nginx: How to install nginx 1.9.15 on amazon linux disto sudo chmod 755 /etc/rc.d/init.d/nginx sudo service nginx start sudo chkconfig nginx on Then I used scp to copy our Django app to this path: /usr/share/lynette-ecomerce-demo Then, as the regular EC2 user ec2-user I ran: source bin/activate pip install Django pip install gunicorn If I run python and then this: >>> import sys >>> print(sys.prefix) /usr/share/lynette-ecomerce-demo/ecommerce-site/version1/django … -
form.clean() is called when generated
I'm generating a standard form together with TemplateResponse. My problem is that the form is being rendered already validated (shows validation errors) when it shows. I see in the logs only 1 request to the server. What can cause it to pre-validations? I"m using Django 1.6 Thanks -
How to implement react with material ui along with python-django
I need help to implement react with material ui components in web application. The following key technologies i worked on for several projects: Backend : Python-Django (MySQL) Frontend : Materialize CSS, Javascript, Jquery. The following key technologies that i want to work with for new projects: Backend : Python-Django (MySQL) Frontend : Material UI, React So can you guys help me out to implement this. Is it good idea to work with react or to have Angular ? Do i need to switch to other database ? References : https://medium.com/codingthesmartway-com-blog/getting-started-with-material-ui-for-react-material-design-for-react-364b2688b555 https://medium.com/@TechMagic/reactjs-vs-angular5-vs-vue-js-what-to-choose-in-2018-b91e028fa91d -
Error in Django Admin Site during template rendering- '__str__ returned non-string (type bytes)'
I would like to access a model in the admin panel of my Django app- http://127.0.0.1:8000/admin/scraper/ad_history/ When i click the model link to view its entries, i get the following error: TypeError at /admin/scraper/ad_history/ __str__ returned non-string (type bytes) Request Method: GET Request URL: http://127.0.0.1:8000/admin/scraper/ad_history/ Django Version: 2.1 Exception Type: TypeError Exception Value: __str__ returned non-string (type bytes) Exception Location: C:\Python36-32\lib\site-packages\django\contrib\admin\templatetags\admin_list.py in items_for_result, line 251 Python Executable: C:\Python36-32\Anaconda\python.exe Python Version: 3.6.5 Python Path: ['C:\\MyApp\\MyApp', 'C:\\Python36-32\\python36.zip', 'C:\\Python36-32\\DLLs', 'C:\\Python36-32\\lib', 'C:\\Python36-32', 'C:\\Python36-32\\lib\\site-packages', 'C:\\Python36-32\\lib\\site-packages\\win32', 'C:\\Python36-32\\lib\\site-packages\\win32\\lib', 'C:\\Python36-32\\lib\\site-packages\\Pythonwin'] Server time: Tue, 21 Aug 2018 14:05:36 +0000 __str__ returned non-string (type bytes) I tried to change the str function in the model to return a dummy string (to ensure there were no bytes being returned) and this still generated the error. Any ideas how i can get to the bottom of this? -
Django Sitetree translate
I have an application with a backend made in Django. The application has the option of the Spanish and English language, where I make the translation of all the sections through a django.po file. What I want to do is to be able to translate the sitetree (that is, the entire menu) that is made in English to Spanish. Does anyone have any idea how to do it? Thank you very much for your time. -
'ReverseManyToOneDescriptor' object has no attribute 'all'
I'm new to Django and I'm trying to access products that belong to category through Category model. I'm using a foreign key in Product for categories. These are my models: class Category(models.Model): name = models.CharField(max_length=140) slug = models.SlugField(blank=True) def __str__(self): return self.name def get_absolute_url(self): return reverse("shop:category", kwargs= {"category_slug": self.slug}) class Product(models.Model): category = models.ForeignKey(Category, on_delete=models.CASCADE) brand = models.ForeignKey(Brand, on_delete=models.CASCADE) title = models.CharField(max_length=200) slug = models.SlugField() description = models.TextField() image = models.ImageField(upload_to=image_name) price = models.PositiveIntegerField() avaliable = models.BooleanField(default=True) def get_absolute_url(self): return reverse("shop:product", kwargs={ "product_slug": self.slug, "product_ctgr_slug": self.category.slug,}) My Views: class CategoryDetailView(DetailView): model = Category category_products = Category.product_set.all() slug_url_kwarg = "category_slug" def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context['categories'] = self.categories context['category_products'] = self.category_products return context But Django gives me an AttributeError: 'ReverseManyToOneDescriptor' object has no attribute 'all'. What am I doing wrong? -
Which one to choose Node.js or Django for e-commerce website development?
I'm going to develop e-commerce website for final year project. But I'm confused, Which language is preferable node.js or django. I have good knowledge in html, bootstap, JS, nodejs and mongodb. I know python(intermediate level). I know Node.js is capable or efficient for this project. Does django too. Thank you! -
Ouath for already registered users
I am implementing oauth with google in django using allauth. I have many users registered to site already. Is there any way to provide oauth using google to them, so that the data will be saved in SocialAccount model and connected to corresponding user based on email of the user in User model?? Thanks for all the help -
Why json parsing serializer is not working for nested json in Django Rest Framework?
I am implementing json API using Django Rest Framework. Since sqlite is being used for database, json data is stored as string and when the data is requested, serializer parse the string and convert into json and sent to client side. This implementation worked for simple json file as shown in left picture. However, this cannot work for nested json as shown right picture. Can anyone tell me how I should revise serializer in order to work for nested json also? serializer.py class strToJson(serializers.CharField): def to_representation(self,value): x=JSON.loads(value) return x class summarySerializer(serializers.ModelSerializer): project=serializers.CharField(read_only=True,source="html.project") version = serializers.CharField(read_only=True, source="html.version") id = serializers.IntegerField(read_only=True, source="html.pk") json = strToJson() class Meta: model=summary fields=('id','project','version','json') model.py class summary(models.Model): html = models.ForeignKey(html, on_delete=models.CASCADE,related_name='summaries') keyword = models.CharField(max_length=50, default='test') json = models.TextField(default='test') -
running OpenAI gym library in website
I have a website and there is a python editor inside it. In this editor there is code for using OpenAI gym library like this: import gym env = gym.make('CartPole-v0') for i_episode in range(20): observation = env.reset() for t in range(100): env.render() print(observation) action = env.action_space.sample() observation, reward, done, info = env.step(action) if done: print("Episode finished after {} timesteps".format(t+1)) break I run this code inside my back end like this (and it's work fine): cmd = 'python ' + my_session["file_name"] p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True) output = p.stdout.read() but this library has a video as an output that shows the game, from the documentation of gym https://github.com/openai/gym#rendering-on-a-server I understand that I should use xvbf inorder to show the result of code to the client. but as I run the command below no change happens and the output is not shown. Should I do something else after this command? xvfb-run -s "-screen 0 1400x900x24" bash -
Django - getting the value of date in html input tag
I'm trying to set a date as the value of a date input in a form. But, as your may have guessed, it's not working. Here's what I have in my template: <form method="POST"> {% csrf_token %} <label for="address">Address:</label> <textarea name="address">{{user.address}}</textarea> <label for="DOB">DOB:</label> <input type="date" name="DOB" value="{{user.dob|date:'Y-m-d'}}"> <button type="submit">Submit</button> <button type="reset">Reset</button> <a href="{% url 'view_profile' %}">cancel</a> Here is my model: sys_id = models.AutoField(primary_key=True, blank=True) email = models.EmailField( verbose_name='email address', max_length=255, unique=True, ) first_name = models.CharField(max_length=50,blank=True,null=True) last_name = models.CharField(max_length=50,blank=True,null=True) address = models.TextField(max_length=300,blank=True,null=True) DOB = models.DateField('Date of Birth', blank=True, null=True) DOJ = models.DateTimeField(auto_now=True) active = models.BooleanField(default=True) staff = models.BooleanField(default=False) # a admin user; non super-user admin = models.BooleanField(default=False) Here is my form: class EditProfileForm(UserChangeForm): class Meta: model = User fields = ('address','DOB','password') Here is my Views: def edit_profile(request): if request.method == 'POST': user_form = EditProfileForm(request.POST or None,instance=request.user) if user_form.is_valid(): user_form.save() return redirect('view_profile') else: user_form = EditProfileForm(request.POST or None,instance=request.user) return render(request,'edit_profile.html',{'user_form':user_form,}) I have 2 problems 1: when I am editing my profile unable to get the value of Date of birth in my edit page. 2: while registration I am unable to get the calendar in the form registration so I can't tell the user format of entering the DOB its just Displaying … -
change model property by another property django
I have model Word class Word(models.Model): group_id = models.IntegerField() old_group_id = models.IntegerField(default=0) I have some word query: words = Word.objects.filter(...) Right now I want every word to set old_group_id to group_id something like words.update(old_group_id=group_id) So far I am doing it by iterating through every word, but this doesn't feel very effective: for word in words: word.old_group_id = word.group_id word.save() -
Django - override save method
I'm overriding the save() method for a model in Django, but it's not working properly. I want the book_quantity to update automatically each time when, I edit the number of books in a cart and click save button. For instance: I've already changed the number of the book from 0 to 11 and clicked the save button, but the book_quantity still showing number 0 (the previous number). If I change the number from 11 to 22 or not change the number then click the save button again. The book_quantity will be 11. So it always shows the previous number. But what I want is that the book_quantity changes immediately each time when I click the save button (once). cart/models.py class Cart(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, null=True) book_quantity = models.IntegerField(default=0) total_price = models.DecimalField(max_digits=10, decimal_places=2, default=0) def __str__(self): return self.user.email + '_cart' def save(self, *args, **kwargs): self.book_quantity = 0 books = BooksInCart.objects.filter(cart__user=self.user).values('quantity') for i in range(len(books)): self.book_quantity += books[i].get('quantity') super().save(*args, **kwargs) class BooksInCart(models.Model): cart = models.ForeignKey(Cart, on_delete=models.CASCADE) book = models.ForeignKey(Book, on_delete=models.CASCADE) quantity = models.IntegerField(default=1) def __str__(self): return self.book.title -
Django queryset models through an intermediate model
I have a a model A (Meeting) that is related to model B (Signup). model B is related to model C (Attendee). Models: Meeting id, date Signup id, meeting (FK to Meeting.id), other fields Attendee signup (FK to Signup.id), other fields How do I make a queryset on Meeting.objects that will also return the other fields in Signup and Attendee? I need all data for a report. I'd prefer not to change my models because this seems like this should be doable the way they are. I'd also like to query Meeting because I have some other stuff in the query that Meeting is needed for (removed for simplicity). Here's what I currently have: qs = Meeting.objects.filter(id__in=queryset).prefetch_related('signup').annotate(attendee_signup=F('signup__attendee_signup')) I keep getting "cannot resolve keyword attendee_signup into field" I also have tried variations of: qs = Meeting.objects.filter(id__in=queryset).select_related('signup').filter(attendee__signup=signup_id) I get "name 'signup_id' is not defined" I'm brand new to python and Django and I don't know if I need to use F and/or annotate, prefech_related or select_related. I've looked up what each does, but I can't find the right syntax to get this working. I feel like I've tried every combo and I'm just mashing keys at this point. Could someone help please? -
502 bad gateway while file upload nginx+gunicorn
I want to upload upto 5 gb video on my website. I have done the configuration on one of my server and it is working fine and for the other one I'm getting "502 bad gateway" message nginx config server{ listen 80; server_name admin.matrixpartners.in 35.154.26.69; client_max_body_size 5120M; location = /favicon.ico {access_log off; log_not_found off;} location /{ include proxy_params; proxy_connect_timeout 3000s; proxy_read_timeout 3000s; proxy_pass http://unix:/home/ubuntu/matrix/matrix.sock; } } and the gunicorn.service is as [Unit] Description=gunicorn daemon After=network.target [Service] User=root Group=www-data WorkingDirectory=/home/ubuntu/matrix ExecStart=/home/ubuntu/matrix/matrixenv/bin/gunicorn --access-logfile - --workers 3 --bind unix:/home/ubuntu/matrix/matrix.sock matrix.wsgi:application [Install] WantedBy=multi-user.target The same config i have defined for other server and it is working. Please suggest a fix for this