'Django SECURE_HSTS_SECONDS preventing access

I have a Django application deployed on a Linux virtual machine using Nginx as a reverse proxy.

The website used to work very well and was accessible by users via HTTPS. However, I have set SECURE_HSTS_SECONDS = 3600 in the settings.py. This blocked access to the website, resulting in a timeout and a status code of 301.

I then commented out this line of code. I expected the application to be accessible by users after an hour or so, since the variable SECURE_HSTS_SECONDS was set to 3600 seconds, but it still remains unaccessible.

My relevant settings are:

if not DEBUG: # Production settings
    SESSION_COOKIE_SECURE = True 
    CSRF_COOKIE_SECURE = True 
    SECURE_SSL_REDIRECT = True 

    # SECURE_HSTS_SECONDS = 3600 # NOTICE that this line was present before but is not commented out 
    SECURE_HSTS_PRELOAD = True
    SECURE_HSTS_INCLUDE_SUBDOMAINS = True

Any idea as to why this might be the case?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source