ERR_CONNECTION_CLOSED after clicking on password reset link

One of the users on my website wanted to reset their password but when they clicked on the link sent to their email, the password reset form page isn’t shown but rather an ERR_CONNECTION_CLOSED page.
So I tested this and also got the same results.
There are no errors shown on my website’s error logs in PythonAnywhere (hosting platform) and when I tried to check if the password reset was working locally, I was taken to a “not secure” page of Godaddy (my domain hosting platform) which says welcome to “mydomain.com”.

Since I couldn’t find any errors, I don’t know where to start on how to fix this issue or which part of my code I should show. What could be the problem?

We’re probably going to need to see the complete error message along with the URL being accessed to begin to diagnose something like this.

This is the URL being accessed:
(https://isowservices.com/reset/MQ/aw0r09-1e98dfd21ed7341c8fceb30327610ff2/)

As I mentioned before, there was no error message in the terminal when I tested this locally and no error message shown in the live website error logs. But this is a screenshot of the page shown on Microsoft Edge

Ok, so lets check this element by element:

  • Do you have https set up? (Do other pages work across https?)

  • Do you own isowservices.com?

    • Is it set up in DNS to point to your server?
  • Have you verified that your site works with any other path?

Yes. The website is using the " Let’s Encrypt certificate". And also, the other pages work across https

Yes. I own the website and the domain name.

Yes. I have PythonAnywere’s server CNAME set up in my domain settings in GoDaddy

I’m sorry. I don’t understand what you meant with this question

You answered that earlier. The rest of your site is working aside from this.

Next thing to check then is the view. What is the view associated with this url? Is it a view you’ve written or one of the standard system views?

The email template being used is from the standard system one.

{% load i18n %}{% autoescape off %}

{% blocktranslate %}You're receiving this email because you requested a password reset for your user account at {{ site_name }}.{% endblocktranslate %}

{% translate "Please go to the following page and choose a new password:" %}

{% block reset_link %}

{{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %}

{% endblock %}

{% translate 'Your username, in case you’ve forgotten:' %} {{ user.get_username }}

{% translate "Thanks for using our site!" %}

{% blocktranslate %}The {{ site_name }} team{% endblocktranslate %}

{% endautoescape %}

I have a view that sends a custom email to newly registered users so that they can set their passwords through a link but it shouldn’t affect the normal reset password workflow as it only activates when the register form is submitted.

Ok, but what is the view that is supposed to handle /reset/MQ/… urls? Is your urls.py file routing this URL correctly?

It is the standard PasswordResetConfirmView

path("reset/<uidb64>/<token>/",auth_views.PasswordResetConfirmView.as_view(template_name="accounts/password_reset_form.html"),
name="password_reset_confirm"),

Is this your template or is it loading the standard system password reset template?

Its my template.

{% extends 'home/base.html' %}
{% load static %}

{% block heading %}
    <style>
        body{
            background-color: #ebeff5;
        }
    </style>

{% endblock %}

{% block content %}

<section id="password_reset_form">
    <div class="container">
        <div class="password_reset_form_box">
            <div class="form_heading">
                <h1>Enter your new password</h1>
            </div>

            <p class="help_text">Please enter your new password twice so we can verify that you typed it in correctly.</p>

            <form method="post">
                {% csrf_token %}

                {% for non_field_error in form.non_field.errors %}
                    <p class="error_message">{{ non_field_error }}</p>
                {% endfor %}
                {% for field in form %}
                    <div class="field_wrapper">
                        {{field.label}}
                        {{field}}

                        {% for error in field.errors %}
                            <p class="error_message">{{error}}</p>
                        {% endfor %}

                    </div>
                {% endfor %}
                
                <button type="submit" class="success_btn"> Update Password</button>
                
            </form>
        </div>
    </div>
</section>
   

{% endblock %}

First suggestion would be to remove the use of the custom template from the as_view call in the url. See if it works with the standard template.

Okay. I did what you suggested on localhost but then I get a blank page with this text “Not Found 404.0”.
Now I do want to mention that I’ve noticed that on localhost the url link in the password reset email uses my live website’s domain name instead of the localhost server name. This is the url shown on the reset email locally.

http://isowservices.com/reset/Mg/aw1ww5-b0e3740e71dd4b97558591e10d0201c8/

While I was setting up the custom welcome email for new users, I had to add my website’s domain name to the sites in the Django admin so that the {{site_name}} shown at the end of the default email template is not “example.com”. So I’m guessing that this is what is causing the default email template to use the sites domain name instead of the localhost.

{{ protocol }}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %}

Nonetheless, I had tested the password reset before on both local and live and it was working. And even if the sites issue is the culprit locally, it shouldn’t be a problem for the live version of the website, which is actually on the domain. So I don’t think the overarching issue here is the sites.