Good day,
i have currently my django project running on an aws server. I have used Nginx and configured it all. The application is running, but when i try to login via the login page i have created or try to login via the admin panel it gives me a Server Error (500). I have my DEBUG=False and added my server dns to ALLOWED_HOSTS. As for the Database. I have got my SQL Database running on an Azure server and used environment variables (that i have permanently set in my ubuntu terminal) to get my password and username.
I have also tried to set DEBUG to False and trying to figure out the issue when running python manage.py runserver so i could experiment with it on my localhost, but no luck. I cant access 127.0.0.1 eventhough i have added it to my Allowed hosts.
How could i see what the error is? Thank you in advance
Ok, so fixed it!
After each change, you simply run the command sudo supervisorctl reload in your powershell after you ssh'ed into your aws ec2 server.
As for seeing what the error is, simply set DEBUG=True
Related
I followed the tutorial (https://aws.amazon.com/getting-started/hands-on/deploy-python-application/) on deploying Django website in AWS Lightsail. When I use the
python3 manage.py runserver 0.0.0.0:8000
to deploy the website then it works perfectly and I can access the website at http://AWS.INSTANCE.PUBLIC.IP.ADDRESS:8000
However, if I follow the Host the application using Apache part of the same tutorial, I am getting the following error when I try to access http://AWS.INSTANCE.PUBLIC.IP.ADDRESS:
Internal Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator at you#example.com to inform
them of the time this error occurred, and the actions you performed
just before this error.
More information about this error may be available in the server error
log.
How to successfully deploy the Django website/app using Apache on AWS Lightsail instance?
I was able to run Django on lightsail by following the tutorial.
Make sure all paths in bitnami.conf file is correctly configured. Also, you need to retain the below part.
# Let Apache know we're behind a SSL reverse proxy
SetEnvIf X-Forwarded-Proto https HTTPS=on
This is the part where the tutorial asks to delete but don't delete this part. Below this part, should start.
If you were able to put up the correct paths, you should be able to run Django application on LightSail.
However, there is a bigger problem later on when you try to get HTTPS on lightsail instance;;;
I'm working with Django Rest Framework and Django Rest Framework JWT, but I'm running into an issue in regards to local behavior vs external behavior.
When I make a POST request to get a JWT token, everything works as desired both locally and on my EC2 instance. However, once I have the token, when I make a request to my server that requires authentication, only my local server returns the expected response. On my deployed server, I get the following error:
{"detail":"Authentication credentials were not provided."}
What I've tried so far:
Editing http.conf by sshing into my server and enabling WSGIPathAuthorization. (saw a similar post here and tried the solution)
What could be causing this behavior? My local machine and my deployed code are identical, leading me to believe that this has something to do with server-side configuration.
All help is appreciated. Thanks!
You mentioned ElasticBeanstalk.
You can add this to your container commands which will be executed during deployment.
01_wsgipass:
command: 'echo "WSGIPassAuthorization On" >> ../wsgi.conf'
Simply restarting Apache after enabling WSGPPathAuthorization fixed my error. For those of you who encounter something similar, here's what I did:
SSH into the server
Navigate to where your http.conf file is stored (in Apache, this is usually
etc/httpd/http.conf)
Edit http.conf, adding WSGIPathAuthorization On.
Restart Apache by running sudo service httpd restart.
This problem usually occurs when you do configure wsgi with apache on EC2 instance.
Bascially its the problem in apache configuration,
it has nothing to do with AWS EC2.
As apache bydefault do not process Authorization headers, so in order to make that happen we need to configure its files.
For ubuntu
cd /etc/apache2/apache2.conf
paste the following line
WSGIPassAuthorization On
I am trying to set up a Django website on an Ubuntu server hosted on DigitalOcean.
After following the step-by-step DigitalOcean tutorial here: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04
I remain stuck as I cannot seem to access Django's development server launched on 0.0.0:8000 with the browser of my local machine. However, I do have a response using -curl from the server's bash terminal. So it seems it can only be accessed from the server itself. Django does not return any error while launching the development server. It lists successful connections (code 200) every time I access it via -curl, but does not show anything when I try to access it via my external browser, as if it is actually not being acecssed.
What I did:
followed this tutorial step-by-step until the launch of Django's development server,
disabled Ubuntu's firewall and no DO firewall is used
added '*' in ALLOWED_HOSTS in settings.py
Any ideas? Thank you very much!
I've followed all steps required to configure Django with GAE + Google Cloud SQL (on Windows 7) but I am unable to authenticate (OAuth2) and run syncdb remotely. When I run manage.py syncdb the browser pops up and I am requested to allow access, but when I do that nothing happens. The browser is forwarded correctly to my local django instalation (the typical It worked! screen) but no OAuth2 token is in %USERPROFILE%\ and the console gets frozen:
C:\Users\me\myproject>python manage.py syncdb
Your browser has been opened to visit:
https://accounts.google.com/o/oauth2/auth?state=None&redirect_uri=http%3A%2F%2Flocalhost%3A8080%2F&response_type=code&client_id=my_id.apps.googleusercontent.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fsqlservice&access_type=offline
If your browser is on a different machine then exit and re-run this
application with the command-line parameter
--noauth_local_webserver
There is no error message and I have to kill the console.
Anybody has faced a similar issue? Is there any log somewhere in GAE I can check?
I had the same problem, only on OS X.
I never figured out why, but it went away after a reboot.
I had the same issue, but it was because I had local appengine server running while I was running manage.py syncdb. Shutting it down and trying again worked as intended.
hope that helps.
I finally got my Django app to deploy on Heroku, using Vagrant and Postgres for both local and production. The localhost is up and running, and I'm in the admin, adding users. But when I run
heroku run python manage.py syncdb
it barfs up this error:
psycopg2.OperationalError: could not connect to server: No such file or directory
Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Same thing happens when I try to access the admin online: http://vast-sierra-7949.herokuapp.com/admin/
I'm new to Heroku, and I've tried just about every getting started tutorial I could find, including
http://gettingstartedwithdjango.com/en/lessons/introduction-and-launch/
https://devcenter.heroku.com/articles/django,
https://github.com/callmephilip/django-heroku-bootstrap, and
https://github.com/jpadilla/django-project-template
This last github link actually allowed me to deploy, before I was just getting an error when I ran
git push heroku master
and that error was: manage.py: error: no such option: --noreload
I know there are several posts with this error, but I've looked through as many as I could find with no luck on resolving the issue.
Thank you in advance,
Anthony
Be sure to setup heroku DB settings
Check out this blog post: http://jamie.ideasasylum.com/2012/09/connecting-navicat-to-postgresql-on-vagrant/
The author talks about how you have to modify pg_hba.conf by adding the following lines to allow a host machine (in this case, you Heroku instance) to connect to a postgres server installed on a guest VM within the host.
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all 10.0.2.2/32 md5
I'm not sure if you can access these files on a Heroku instance, but it's a place to start. Good luck!