[Fixed]-403 CSRF errors when trying to login to Django Admin over an SSH tunnel

1👍

Django will see that you’re trying to access my.website.com domain and it will send back to you cookie for that domain.

But your browser is actually accessing localhost domain, so cookies for my.website.com won’t be valid for it and browser won’t send them back to Django server.

One way to fix it is to point my.website.com to 127.0.0.1 using /etc/hosts, change your tunnel port to 443 and connect to my.website.com instead.

Another approach is to set any server in between you and your django server that will rewrite cookies and other paths from one domain to another.

Leave a comment