CSRF Verification error appeared after I changed DNS

92 views
Skip to first unread message

Saqib Ali

unread,
Jan 8, 2013, 11:44:49 PM1/8/13
to django...@googlegroups.com


Hi.

I have been using Django successfully for a few days now. I was running my django application on an Amazon Web Service machine. 
I was assigned some arbitrary DNS name that looked like this: http://ec2-XXX.XXX.XXX.XXX.compute-1.amazonaws.com.
My Django app was working find with my model and several views with templates.

Last night, I went out and bought a real DNS name from register.com and have that DNS name now pointing to my django application.
Since I made that change however, when I submit my django form, I get the following CSRF error:



Forbidden (403)

CSRF verification failed. Request aborted.



I tried clearing the cookies in my browser, but that didn't help. I even tried it from other machines that I had never tried before. But still the same problem.

Why did assigning a new DNS name for this IP address cause this CSRF error? And how do I get rid of it?


Saqib Ali

unread,
Jan 9, 2013, 12:19:35 AM1/9/13
to django...@googlegroups.com
BTW, I forgot to mention that my template contains the following HTML:

    <form action="/forgotUserName2" method="post">{% csrf_token %}

    <label for="id_email">E-mail:</label></th><td><input id="id_email" type="text" class="required" name="email" maxlength="75" />
    <input type="submit" value="Submit" />
    </form>

Amirouche

unread,
Jan 9, 2013, 1:09:03 AM1/9/13
to django...@googlegroups.com
Did you check your cookies, is there any csrftoken ?

Did you change SESSION_COOKIE_DOMAIN ?

Saqib Ali

unread,
Jan 9, 2013, 2:21:08 AM1/9/13
to django...@googlegroups.com
Yes, I checked my cookies and there is a csrftoken: jrQ4T0IZPqFpbjoPLlzJSnsEPQxzHAJh
I didn't change the SESSION_COOKIE_DOMAIN value. There is no such setting in my settings.py.

I did no

Amirouche

unread,
Jan 9, 2013, 2:35:53 AM1/9/13
to django...@googlegroups.com


On Wednesday, January 9, 2013 3:21:08 AM UTC+1, Saqib Ali wrote:
Yes, I checked my cookies and there is a csrftoken: jrQ4T0IZPqFpbjoPLlzJSnsEPQxzHAJh
I didn't change the SESSION_COOKIE_DOMAIN value. There is no such setting in my settings.py.


I don't know then : /

Maybe restart gunicorn or whatever runs django...

Jun Tanaka

unread,
May 15, 2015, 6:53:00 PM5/15/15
to django...@googlegroups.com
I got the same kind of an error.

In my case, I got u'CSRF_COOKIE' instead of 'csrf' in request.

I appreciate any solution for this issue.



2013年1月9日水曜日 8時44分49秒 UTC+9 Saqib Ali:
Reply all
Reply to author
Forward
0 new messages