Django Cookiecutter Production Login Fails With No Explanation/Log
See original GitHub issueI am struggling to take my Django project live using Docker on DigitalOcean where I use Django cookiecutter. Everything works fine in development (where I don’t use Docker, but a simple virtualenv and a local instance of Postgres) But in production when I submit the login form, if there’s an error (the user cannot be authenticated) then I get the message produced by allauth, but if the login is successful, I get redirected to login page, unauthenticated and without any explanation/log.
It is 99.99% user (my) fault, but I am running out of options after 5 hours of struggling. I appreciate any help, and would be willing to provide more info depending on what you might need. Thanks.
Here’s the .env file I use in prod:
# PostgreSQL
POSTGRES_PASSWORD=db_pass
POSTGRES_USER=db_user
# General settings
DATABASE_URL=postgres://db_user:db_pass@postgres:5432/db_name
DJANGO_SETTINGS_MODULE=config.settings.production
DJANGO_SECRET_KEY=*********************
# DJANGO_ALLOWED_HOSTS=.example.com
# DJANGO_ADMIN_URL=
# AWS Settings
# DJANGO_AWS_ACCESS_KEY_ID=
# DJANGO_AWS_SECRET_ACCESS_KEY=
# DJANGO_AWS_STORAGE_BUCKET_NAME=
# Used with email
# DJANGO_MAILGUN_API_KEY=
# DJANGO_SERVER_EMAIL=
# Security! Better to use DNS for this task, but you can use redirect
DJANGO_SECURE_SSL_REDIRECT=False
# django-allauth
DJANGO_ACCOUNT_ALLOW_REGISTRATION=True
# Sentry
DJANGO_SENTRY_DSN=
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Django Cookiecutter Production Login Fails With No ... - GitHub
I am struggling to take my Django project live using Docker on DigitalOcean where I use Django cookiecutter. Everything works fine in ...
Read more >Troubleshooting — Cookiecutter Django 2022.50.3 ...
This page contains some advice about errors and problems commonly encountered during the development of Cookiecutter Django applications.
Read more >Django-Cookiecutter cannot start the default project
You are developing on windows but running on linux container. Normally it is not a problem, but in this case this might be...
Read more >pydanny/cookiecutter-django - Gitter
I have this strange issue. I am using a script that works perfect on Docker Local but in Production Docker it is not...
Read more >Full Deployment of Cookiecutter-Django on DigitalOcean with ...
Whenever there's an issue, check the logs first (as we're no longer in debug mode). $ docker-compose -f production.yml logs. We should now...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh stupid me. I was trying to serve over HTTP, but forgot to comment out
CSRF_COOKIE_SECURE = True
.So making these for lines from:
to:
resolved the issue. @jayfk Thank you for your time and @pydanny, thanks for pointing me at the right direction. I guessed it was a user fault. 😋
@pydanny Thanks for your wishes, we are all safe now.
Here are the
docker-compose logs django
results:Following this is a couple of
Invalid HTTP_HOSTS header
ERRORs from regular port scans, I guess everything is pretty normal at this point.Here is the output for
docker-compose ps
:Again, I am assuming it to be normal (except for the port mapping on postgres service-which I changed to run on the host to see if it will make a difference, everything is as is).