# \[AYUDA\] No se puede iniciar sesión, aparece el error "BAD CSRF"

**URL:** https://meta.discourse.org/t/help-cannot-login-error-shows-bad-csrf/52424
**Category:** Support
**Created:** [3 Noviembre, 2016 09:08 UTC](https://meta.discourse.org/t/help-cannot-login-error-shows-bad-csrf/52424 "2016-11-03T09:08:33Z")
**Posts on this page:** 12
**Page:** 2

<div class="post-metadata">

### Author: ![stephane](https://avatars.discourse-cdn.com/v4/letter/s/dfb087/32.png) [@stephane](https://meta.discourse.org/u/stephane)
#### Post date: [7 Noviembre, 2016 15:35 UTC](https://meta.discourse.org/t/help-cannot-login-error-shows-bad-csrf/52424/21 "2016-11-07T15:35:12Z")

</div>

Hello,

Thank you @sam, the reverse proxy change you suggested worked. I don’t know why my test without it did not reveal it was a proxy problem, or what caused it to appear, but the change worked !

Regards,

Stephane

---

<div class="post-metadata">

### Author: ![Firei](https://avatars.discourse-cdn.com/v4/letter/f/91b2a8/32.png) [@Firei](https://meta.discourse.org/u/Firei)
#### Post date: [9 Noviembre, 2016 18:45 UTC](https://meta.discourse.org/t/help-cannot-login-error-shows-bad-csrf/52424/22 "2016-11-09T18:45:34Z")

</div>

When we have reinstalled discourse it worked for two days and now we have same problem. It happens with a proxy and without the proxy. User cannot login/post/like/register or anything.  
We have updated and rebuild discourse many times and will not work. pls help

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [9 Noviembre, 2016 20:40 UTC](https://meta.discourse.org/t/help-cannot-login-error-shows-bad-csrf/52424/23 "2016-11-09T20:40:37Z")

</div>

As stated above, it’s almost certainly the wrong proxy header, if you are on HTTPS. You could try turning off HTTPS.

---

<div class="post-metadata">

### Author: ![Firei](https://avatars.discourse-cdn.com/v4/letter/f/91b2a8/32.png) [@Firei](https://meta.discourse.org/u/Firei)
#### Post date: [9 Noviembre, 2016 21:50 UTC](https://meta.discourse.org/t/help-cannot-login-error-shows-bad-csrf/52424/24 "2016-11-09T21:50:13Z")

</div>

@codinghorror we haven’t HTTPS enabled

---

<div class="post-metadata">

### Author: ![daxen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/daxen/32/64364_2.png) [@daxen](https://meta.discourse.org/u/daxen)
#### Post date: [24 Noviembre, 2016 10:48 UTC](https://meta.discourse.org/t/help-cannot-login-error-shows-bad-csrf/52424/25 "2016-11-24T10:48:09Z")

</div>

same here:

updated discourse+plugins yesterday.

today users reported login to discourse not possible - already logged in sessions are working fine.

showing login error: “unbekannter fehler / unknown error”  
browser console: “BAD CSRF” and some javascript

fix:  
add this to nginx config:

> proxy\_set\_header X-Forwarded-Proto https;

best regards,  
daniel

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [24 Noviembre, 2016 11:51 UTC](https://meta.discourse.org/t/help-cannot-login-error-shows-bad-csrf/52424/26 "2016-11-24T11:51:13Z")

</div>

If you have http and the site setting force\_https, expect a bad time

---

<div class="post-metadata">

### Author: ![daxen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/daxen/32/64364_2.png) [@daxen](https://meta.discourse.org/u/daxen)
#### Post date: [24 Noviembre, 2016 13:29 UTC](https://meta.discourse.org/t/help-cannot-login-error-shows-bad-csrf/52424/27 "2016-11-24T13:29:53Z")

</div>

No, we only use https.  
it’s all back working again.

---

<div class="post-metadata">

### Author: ![csirac2](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/csirac2/32/61088_2.png) [@csirac2](https://meta.discourse.org/u/csirac2)
#### Post date: [8 Diciembre, 2016 12:02 UTC](https://meta.discourse.org/t/help-cannot-login-error-shows-bad-csrf/52424/28 "2016-12-08T12:02:17Z")

</div>

For what it’s worth, the recent upgrade broke things for us also, in exactly the same way. We have a strictly https-only set of subdomains, and an apache reverse-proxy.

The configuration directive in apache equivalent to the nginx advice above is:

```
RequestHeader set X-Forwarded-Proto "https"

```

Cheers

---

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [25 Agosto, 2019 13:47 UTC](https://meta.discourse.org/t/help-cannot-login-error-shows-bad-csrf/52424/29 "2019-08-25T13:47:18Z")

</div>

A mí también me ocurre lo mismo después de una instalación limpia Y de una restauración (exitosa) desde una copia de seguridad antigua: CSRF incorrecto.

No estoy usando ningún proxy. Sin embargo, accedo al sitio web utilizando una entrada local en mi `/etc/hosts`.

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [25 Agosto, 2019 14:07 UTC](https://meta.discourse.org/t/help-cannot-login-error-shows-bad-csrf/52424/30 "2019-08-25T14:07:14Z")

</div>

¿Y el problema desaparece si el servidor se referencia correctamente en el DNS público?

---

<div class="post-metadata">

### Author: ![meglio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/meglio/32/71444_2.png) [@meglio](https://meta.discourse.org/u/meglio)
#### Post date: [25 Agosto, 2019 14:34 UTC](https://meta.discourse.org/t/help-cannot-login-error-shows-bad-csrf/52424/31 "2019-08-25T14:34:09Z")

</div>

No lo sé: restauré temporalmente un formulario antiguo en un VPS para extraer cierta información.

Si la falta de registros DNS públicos es la causa, ¿hay alguna solución alternativa?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [3 Julio, 2024 18:03 UTC](https://meta.discourse.org/t/help-cannot-login-error-shows-bad-csrf/52424/32 "2024-07-03T18:03:26Z")

</div>



[Previous page](https://meta.discourse.org/t/help-cannot-login-error-shows-bad-csrf/52424.md?page=1)
