I'm trying to deploy the latest changes to my django app, and I keep getting 502 errors. When I look at the logs, I only have this error in the Django logs: Error: %s <type 'exceptions.NameError'>. There's nothing in the Nginx error logs, and the access logs only show the 502 error. It runs fine in development, and it uses the same pip packages as development. How do I debug this?
Edit: This is actually an updated deployment. I had deployed it before without an issue, but something in my latest changes causes it to fail. I just need to know what that change was, but I can't find anything in the logs that would explain it.
I'm using Nginx, Django 1.8, Passenger, and Python 3.4. The server's running Ubuntu 14.04.
Sorry for the vague question, but I don't even know why this is happening.
Edit 2: It looks like there's actually something in the Nginx error log now. It's still vague, but at least it says something now. For the record, it's UnboundLocalError: local variable 'results' referenced before assignment in passenger_wsgi.py. I'm still clueless about why that's popping up now, but at least it's something to work with. Never mind. It's there, but that's just a result of the actual error, not the cause of it. However, the reason I asked this question is because I couldn't find anything in the logs, and now I've actually found something. So, for those of you looking for error logs:
Check your Nginx config files (nginx.conf, config files in sites-available) for the line error_log and check that.
If you're using Passenger and Django, check your passenger_wsgi.py to see if you've included logging. If so, check where it outputs.
It looks like my issue is out of the scope of this question, but I'd still like to leave it up in case anyone else has trouble finding log files.
Related
I can't seem to find much information about my topic online so I figured I'll ask. I'm trying to set up an app on Django and when I try to 'runserver' I get the following error. It runs with no problem when I remove the ldap configurations but when I add it back in I get this error. Anyone have an idea what can be causing this to break? I'm using Ubunut 20.04 on a windows machine.
I'm new to Python and Django, and I'm following this tutorial to learn some Django basics. I keep getting a DisallowedHost error. (Screenshot: https://ibb.co/c1beYG)
As per this post, I added 'chocoberrie.pythonanywhere.com' to the ALLOWED_HOSTS list in settings.py, and I made sure to include it in quotation marks and keep the brackets. I even added it to requests.py, at line 113 (indicated in the error message).
Additional screenshots: https://ibb.co/jwUNnb and https://ibb.co/fbmrfw
I also committed the changes to Git, and I double-checked the repository to make sure that the URL was added to ALLOWED_HOSTS. I also made sure to reupload the changes on PythonAnywhere.
After all that, I'm still getting the error! It's really frustrating, and I don't know what else to do. Any help would be much appreciated!
Note: I did see a way to "disable" this error in this post, but I'm using a newer version of Django, so I don't know how to apply this.
I did the same tutorial! To solve this problem you have to go in the settings.py file of your django application. You will find ALLOWED_HOST setting which will be blank by default. Enter the following replacing your pythonanywhere name with your's:- '<your-pythonanywhere-name>.pythonanywhere.com'
now git pull in bash console and reload the website!
I'm deploying my Python app on GAE using the command line interface, which has always worked without problems. Since yesterday, one of the modules is getting stuck on "Scanning 500 files" and in the end throws following error:
Another transaction by user jong.vincent is already in progress for app: s~replimeapp, version: uno. That user can undo the transaction with "appcfg rollback".
However when I rollback updates for this app, the error is still thrown on the next deployment. No clue what I can do to resolve this. There is another module which refers to the same files, which has no problem deploying. No clue what I can do to get rid of this. Help please!
Changed the name of the module and then it worked. Very strange, but at least the problem is solved.
I have been working on a localhost copy of my Django website for a little while now, but finally decided it was time to upload it to PythonAnywhere. The site works perfectly on my localhost, but I am getting strange errors when I do the initial migrations for the new site. For example, I get this:
mysql.connector.errors.DatabaseError: 1264: Out of range value for
column 'applied' at row 1
'applied' is not a field in my model, so this error has to be generated by Django making tables for its own use. I have just checked in the MySQL manager for my localhost and the field 'applied' appears to be from the table django_migrations.
Why is Django mishandling setting up tables for its own use? I have dropped and remade the database a number of times, but the errors persist. If anyone has any idea what would cause this I would appreciate your advice very much.
My website front end is still showing the Hello World page and the Admin link comes up with a page does not exist error. At this stage I am going to assume this is related to the database errors.
EDIT: Additional information about why I cannot access the front-end of the site:
It turns out when I am importing a pre-built site into PythonAnywhere, I have to edit my wsgi.py file to point to the application. The trouble now is that I don't know exactly what to put there. When I follow the standard instructions in the PythonAnywhere help files nothing seems to change. There website is also seems to be very short on detailed error messages to help sort it out. Is there perhaps a way to turn off their standard hello world placeholder pages and see server error messages instead?
As it says in my comment above, it turns out that the problem with the database resulted from running an upgrade of Django from 1.8 to 1.9. I had forgotten about this. After rolling my website back to Django 1.8, the database migrations ran correctly.
The reason why I could not access the website turned out to be because I had to edit the wsgi.py file, but I was editing the wrong version. The nginx localhost web server I was using keeps it in the different folder location than PythonAnyhwere's implementation. I uploaded the file from my localhost copy and edited it according to the instructions on PythonAnywhere's help system without realizing it was not being read by PythonAnywhere's server. What I really needed to do was edit the correct file by accessing it through the web tab on their control panel. Once I edited this file, the website front end began to work as expected.
This issue occurred for me as well on version 1.10 with a brand new project. I found that if you use the recommended driver and the connector in the documentation, the migration works without issues.
If you don't feel like reading the docs, in breif:
Install MySQLdb for python 2.7 or mysqlclient for python 3.3+
Modify your settings.py file. In the DATABASES dictionary set:
'ENGINE': 'django.db.backends.mysql',
I'm using Openshift with Django/Python 3. As of yesterday, I've been unable to update my server. When I push a change, the push is successful. Using SCP to view the files on the server, the updated files are present. Using rhc git-pull downloads the correct files as well. However, the templates are the only thing that actually get changed on the app by the push. No changes to python files cause an effect on the app.
When I try to use 'rhc tail', I get the following error:
OSError: [Errno 98] Address already in use
Searching this error leads me to believe there are multiple server processes running for my app. I'm not sure how to run suggested diagnostics, as I don't control the server. Any ideas? Restarting the app does not fix it. Running rhc stop appears to successfully stop the app, yet my website works unhindered. (I've never tried stopping before, but assume it's supposed to kill the website.)
I found this post this afternoon by somebody having the same problem. It looks like Openshift changed some things on us. I didn't get the memo :(.
Read here:
Openshift March Blog post
#MSDOS, it is similar to your answer but I wanted to post the generic answer that is probably affecting most people.
For me, I just had to rename app.py (my old wsgi entry point) to wsgi.py and everything worked as it should. :) Now I have to figure what they changed to the cron jobs :(
Solved by executing 'rhc app force-stop', then 'rhc app start'. I don't know what caused the problem, but force-stopping it killed the website, and it worked with the new code after starting it again.
I think I solved the problem.
I was using an old django repository, based on https://github.com/openshift/openshift-community-cartridge-python-3.3/blob/master/template/app.py (the link is dead, I mentioned here just for information).
In these old community cartridges, there was a app.py file that started CherryPy or httpd, but now the official django repository doesn't have app.py anymore. (check https://github.com/openshift/django-example)
The app.py doesn't exist anymore because httpd service was added automatically. That's why we were having OSError: [Errno 98] Address already in use.
Removing the app.py from my repository solved the problem.
I was receiving error 500 because my Django application was having errors, not my Python cartridge. That's why I wasn't understanding what was happening. I did a find . -name *.log* in my cartridge and read all logs.
Now my app is working. Good luck!