404- error , The requested URL /accounts/google/login/callback/ was not found on this server.

Hi All,

I am using allauth to authenticate my application with google api which is set in my Google cloud application. I am able to login successfully but after login it’s not redirecting to home page .
I am following these steps to setup my application -

Here is the error .

The requested URL /accounts/google/login/callback/ was not found on this server.

Hi Saila, can you please provide us with your urls.py file(s) and the value of the ROOT_URLCONF setting?

1 Like

Hi Tim,
The my_project.urls.py is

from django.contrib import admin
from django.urls import path,include
from django.views.generic import TemplateView

urlpatterns = [
path(’’, TemplateView.as_view(template_name=“social_app/index.html”)),
path(‘admin/’, admin.site.urls),
path(‘accounts/’, include(‘allauth.urls’)),
]

and in setting the root_urlconf =my_project.urls

I want to get the page back after successfully login from the Google account.

Thanks,
Saila

The setting ROOT_URLCONF should be as follows in your settings file: (you may have this already, but I want to make sure we’re on the same page)

ROOT_URLCONF = "myproject.urls"

Are you able to browse tot he admin page and/or get the social_app/index.html template to render at the root path? I’m trying to determine if the issue is with the allauth integration or if it’s in your general project setup.

As a note, when you share code please try to copy and paste it and apply the code formatting to it. That can be done with three leading backticks (`) and then three more backticks following the code. You can also indent the text or highlight it and select the Preformatted Text button on the WYSIWYG editor (Ctrl+Shift+C). Doing so makes it easier to read and spot mistakes that are easier for fresh eyes to find.

Hi Tim,
Thanks for trying to help me . Yes I am able to login the admin page and I am able to access index.html . Also it’s redirecting to account.google.com and after successful login , it should again redirect to index.html which is not working.

Sure , I will follow the codding pattern.

Alright so it appears it’s a configuration issue. Can you please share what you can of your settings file?

Hi saila, I hope I can help you. If the error you get is: /accounts/google/login/callback/ it means that the process is finished, but it needs a url to redirect to when the process finishes, if it returns that error it is because you have not specified a callback route.

In my projects, I have it configured as follows in ‘settings.py’:

LOGIN_REDIRECT_URL = ‘home’.
ACCOUNT_LOGOUT_REDIRECT = ‘home’.

where ‘home’ is the name of my home template.

Hi Minuke,
This is already set in my setting.py also .

SITE_ID = 2
LOGIN_REDIRECT_URL = ‘’
ACCOUNT_LOGOUT_REDIRECT = ‘’

Here my urls.py is
urlpatterns = [
path(’’, TemplateView.as_view(template_name=“social_app/index.html”)),
path(‘admin/’, admin.site.urls),
path(‘accounts/’, include(‘allauth.urls’)),
]

During login and after sufessfully login , It has to redirect to ‘’ , here index.html

And in my index.html I have if …else condition .

{% if user.is_authenticated %}

Welcome, {{ user.username }} !

{% else %}
Login with Google
{% endif %}

Please let me know if you can help me further .

Hi Tim,
I am following In 5 mins: Set up Google login to sign up users on Django | by Zoe Chew | Medium setting changes .

in setting.py ,
LOGIN_REDIRECT_URL = ‘’

and the url.py is

urlpatterns = [
path(’’, TemplateView.as_view(template_name=“social_app/index.html”)),
path(‘admin/’, admin.site.urls),
path(‘accounts/’, include(‘allauth.urls’)),
]

Per the article’s step 4, shouldn’t you set LOGIN_REDIRECT_URL to '/'?

This should be solved by putting a destination in ‘LOGIN_REDIRECT_URL’. Can be you don’t have typed well the address of the callback in step 7 of the guide: http://127.0.0.1:8000/accounts/google/login/callback/

Anyway, if it returns that error, it means that it is working fine, but it doesn’t know which view to go to when it exits google authentication.

As Minuke indicates, you have to put the correct host and port for your dev server, otherwise your browser will try to go to port 80 on the redirect.

This is tested and same issues again.

Hi Minuke,
Thanks for helping out here . I am using my production url which is already hosted with port 80.

I run my application like - > python manage.py runserver ...:80

and I set the GCP credentials like below

Authorized JavaScript origins

Authorized redirect URIs

Also without port it’s showing the same error .

Hi Typonaut,
I am configuring this with my production url and it wil running on port 80 only.

Looks while redirecting it’s asking the loopback ID where , I have to redirect to production url .

There is a question on the stackoverflow -