[Flask] Flask-Security can’t work with Gunicorn with multiple workers

Unai Rodriguez unai at sysbible.org
Tue Jan 10 01:41:56 EST 2017

Hi 王帅,

It seems that somehow your application is storing information that's
only available to the Gunicorn instance that the client connects to.

Have you tested forcing the same user connecting always to the same
Gunicorn instance? That should probably work.

Where are you storing the session information?

-- unai

On Tue, Jan 10, 2017, at 02:11 PM, 王帅 wrote:

> Hello, everyone.


> I’m writing a website with*Flask*. I use *Flask-Security* to do
> authentication and use N*ginx + Gunicorn* to deploy it.

> And I find a problem that *Flask-Security* can’t work with *Gunicorn*
> with multiple workers.

> If the worker number is *one*, I can login normally. If the worker
> number of Gunicorn is *greater than one* or there is *more than
> one* *Gunicorn* servers behind *Nginx*, There are three situations
> will happen:
>  1. It will login normally;
>  2. It will redirect to login page again;
>  3. It will redirect to the page protected by Flask-Security with
>     unlogined status.
> After I expose Gunicorn server to public, It remains. 

> _________________________________________________

> Flask mailing list

> Flask at python.org

> https://mail.python.org/mailman/listinfo/flask

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20170110/014b7c69/attachment.html>

More information about the Flask mailing list