Auth0 Home Blog Docs

500 Server Error on pages requiring login in production (Django / Apache Application)

In development, the pages that I required login (by placing over the view function @login-required) worked beautifully and redirected to Auth0, allowed the user to login and then did a callback to the correct page.
However, once I put the application into production on an Apache server, I can access any pages that don’t require login, but get a 500 Internal Server Error on pages that require a login.
The url does change to http://lsptest.nbn.org.il/login/auth0?next=/IntakeForm/1, but nothing shows up besides the error.

Any suggestions?

Hi it118,

We need more information here to help out.
How is the development env and production env different? Are you using Apache in the dev environment?
What exactly does the server log say for the 500?

John

For the development environment, I was just running Django using localhost. No Apache in the dev env.
Then, for production, I set up an Apache server, made a virtual environment and copied my Django app code over.
The server’s error log is completely blank.

Here’s an example of a view that uses Auth0 that’s affected:

If I run my code like this:
@login-required
def personal_details_section(request):
user = request.user
try:
auth0user = user.social_auth.get(provider=‘auth0’)
except:
return HttpResponse(“test”)
It redirects to http://lsptest.nbn.org.il/login/auth0?next=/IntakeForm/1 and gives me a Server Error (500)

If I take out @login-required, it doesn’t redirect and instead uses my exception and writes “test” on the webpage.

Or if I change it to (no @login-required):
def personal_details_section(request):
user = request.user
try:
auth0user = user.social_auth.get(provider=‘auth0’)
except:
return HttpResponse(user)
http://lsptest.nbn.org.il/IntakeForm/1
Server Error (500)

So it seems clear it must be a problem with authentication. All of my pages that don’t require a login work fine.