librelist archives

« back to archive

upstream prematurely closed connection while reading response header from upstream

upstream prematurely closed connection while reading response header from upstream

From:
Mario Campos
Date:
2013-03-12 @ 18:38
Hi everybody
i'm new here, loving the Flask
But I've been trying to set up a nginx/uwsgi/flask combo on an ubuntu
server and after some trouble got it to work except when i try to write
anything on the database thru the web, i get a 502 from nginx right away
and this on its error logs:

upstream prematurely closed connection while reading response header from
upstream

getting stuff on the db thru the shell works fine tho.
i got it all configured on the nginx configuration file with uwsgi_params
Im not a linux expert so ive no idea what i should be looking for...any
hints are appreciated

-- 

\\\\\\\\\\

Mario Campos Castellano | Motion Design | Compositing | etc

portfolio :: mario.campote.com

+49 1775318616
+34 600 203 395

Re: [flask] upstream prematurely closed connection while reading response header from upstream

From:
Alex Ogier
Date:
2013-03-12 @ 20:28
I have no idea what the cause of your particular problem is, but I can tell
you that apparently something you are doing is crashing uwsgi or python. It
might be as simple as a syntax error in your .wsgi file, or an import error
when you are first loading the app. I would check the uwsgi logs to see if
that helps identify the problem (uwsgi has a lot of logging options, I
don't know what is the default or what you are using).

Some questions to help narrow down the problem search:

If you make a little dummy flask app that doesn't import any database
connectors, does your configuration work?

If you load up your app, but only make a request that doesn't touch the
database, does it work?

Good luck bug hunting!

Best,
Alex Ogier


On Tue, Mar 12, 2013 at 2:38 PM, Mario Campos <mariocampos0001@gmail.com>wrote:

>
>
> Hi everybody
> i'm new here, loving the Flask
> But I've been trying to set up a nginx/uwsgi/flask combo on an ubuntu
> server and after some trouble got it to work except when i try to write
> anything on the database thru the web, i get a 502 from nginx right away
> and this on its error logs:
>
> upstream prematurely closed connection while reading response header from
> upstream
>
> getting stuff on the db thru the shell works fine tho.
> i got it all configured on the nginx configuration file with uwsgi_params
> Im not a linux expert so ive no idea what i should be looking for...any
> hints are appreciated
>
> --
>
> \\\\\\\\\\
>
> Mario Campos Castellano | Motion Design | Compositing | etc
>
> portfolio :: mario.campote.com
>
> +49 1775318616
> +34 600 203 395
>
>

Re: [flask] upstream prematurely closed connection while reading response header from upstream

From:
Teo Klestrup Röijezon
Date:
2013-03-12 @ 21:00
Well, if the error is happening on the side of uWSGI then the nginx logs
probably aren't very useful. Have you checked the uWSGI logs (should be
stdout by default, otherwise you can set it with logto in your config file)?


On 12 March 2013 21:28, Alex Ogier <alex.ogier@gmail.com> wrote:

> I have no idea what the cause of your particular problem is, but I can
> tell you that apparently something you are doing is crashing uwsgi or
> python. It might be as simple as a syntax error in your .wsgi file, or an
> import error when you are first loading the app. I would check the uwsgi
> logs to see if that helps identify the problem (uwsgi has a lot of logging
> options, I don't know what is the default or what you are using).
>
> Some questions to help narrow down the problem search:
>
> If you make a little dummy flask app that doesn't import any database
> connectors, does your configuration work?
>
> If you load up your app, but only make a request that doesn't touch the
> database, does it work?
>
> Good luck bug hunting!
>
> Best,
> Alex Ogier
>
>
> On Tue, Mar 12, 2013 at 2:38 PM, Mario Campos <mariocampos0001@gmail.com>wrote:
>
>>
>>
>> Hi everybody
>> i'm new here, loving the Flask
>> But I've been trying to set up a nginx/uwsgi/flask combo on an ubuntu
>> server and after some trouble got it to work except when i try to write
>> anything on the database thru the web, i get a 502 from nginx right away
>> and this on its error logs:
>>
>> upstream prematurely closed connection while reading response header from
>> upstream
>>
>> getting stuff on the db thru the shell works fine tho.
>> i got it all configured on the nginx configuration file with uwsgi_params
>> Im not a linux expert so ive no idea what i should be looking for...any
>> hints are appreciated
>>
>> --
>>
>> \\\\\\\\\\
>>
>> Mario Campos Castellano | Motion Design | Compositing | etc
>>
>> portfolio :: mario.campote.com
>>
>> +49 1775318616
>> +34 600 203 395
>>
>>
>

Re: [flask] upstream prematurely closed connection while reading response header from upstream

From:
Mario Campos
Date:
2013-03-12 @ 22:37
aha, bummer, im pretty new to all this sysadmin stuff - i wasnt logging to
the /var/log/uwsgi/app/mysite.com.log as i was thinking but to the main
/var/log/uwsgi.log file so i didnt see anything. Feeling pretty dumb about
that. Now i found this in the uwsgi log
sqlalchemy.exc.DataError: (DataError) value too long for type character
varying(20)
aha!i had the password field in the models limited to 20 chars, but the
hashed pw was longer than that.Fixed it now!I am jumping with joy in the
kitchen. thank you guys

The question now is...why did it work on my local environment  but not in
production?its not like the character limit works differently is it?





2013/3/12 Teo Klestrup Röijezon <teo@nullable.se>

> Well, if the error is happening on the side of uWSGI then the nginx logs
> probably aren't very useful. Have you checked the uWSGI logs (should be
> stdout by default, otherwise you can set it with logto in your config file)?
>
>
> On 12 March 2013 21:28, Alex Ogier <alex.ogier@gmail.com> wrote:
>
>> I have no idea what the cause of your particular problem is, but I can
>> tell you that apparently something you are doing is crashing uwsgi or
>> python. It might be as simple as a syntax error in your .wsgi file, or an
>> import error when you are first loading the app. I would check the uwsgi
>> logs to see if that helps identify the problem (uwsgi has a lot of logging
>> options, I don't know what is the default or what you are using).
>>
>> Some questions to help narrow down the problem search:
>>
>> If you make a little dummy flask app that doesn't import any database
>> connectors, does your configuration work?
>>
>> If you load up your app, but only make a request that doesn't touch the
>> database, does it work?
>>
>> Good luck bug hunting!
>>
>> Best,
>> Alex Ogier
>>
>>
>> On Tue, Mar 12, 2013 at 2:38 PM, Mario Campos <mariocampos0001@gmail.com>wrote:
>>
>>>
>>>
>>> Hi everybody
>>> i'm new here, loving the Flask
>>> But I've been trying to set up a nginx/uwsgi/flask combo on an ubuntu
>>> server and after some trouble got it to work except when i try to write
>>> anything on the database thru the web, i get a 502 from nginx right away
>>> and this on its error logs:
>>>
>>> upstream prematurely closed connection while reading response header
>>> from upstream
>>>
>>> getting stuff on the db thru the shell works fine tho.
>>> i got it all configured on the nginx configuration file with uwsgi_params
>>> Im not a linux expert so ive no idea what i should be looking for...any
>>> hints are appreciated
>>>
>>> --
>>>
>>> \\\\\\\\\\
>>>
>>> Mario Campos Castellano | Motion Design | Compositing | etc
>>>
>>> portfolio :: mario.campote.com
>>>
>>> +49 1775318616
>>> +34 600 203 395
>>>
>>>
>>
>


-- 

\\\\\\\\\\

Mario Campos Castellano | Motion Design | Compositing | etc

portfolio :: mario.campote.com

+49 1775318616
+34 600 203 395

Re: [flask] upstream prematurely closed connection while reading response header from upstream

From:
Steven Kryskalla
Date:
2013-03-12 @ 22:48
On Tue, Mar 12, 2013 at 3:37 PM, Mario Campos <mariocampos0001@gmail.com> wrote:
> The question now is...why did it work on my local environment  but not in
> production?its not like the character limit works differently is it?

Are you using SQLite in development? SQLite does not enforce some constraints:

http://www.sqlite.org/datatype3.html

"Note that numeric arguments in parentheses that following the type
name (ex: "VARCHAR(255)") are ignored by SQLite - SQLite does not
impose any length restrictions (other than the large global
SQLITE_MAX_LENGTH limit) on the length of strings, BLOBs or numeric
values."

-steve

Re: [flask] upstream prematurely closed connection while reading response header from upstream

From:
Mario Campos
Date:
2013-03-12 @ 23:03
that would make sense, but i tried both sqlite and postgres both in dev and
production as part of my blind debugging.
It could well have been that my blind debugging was way too blind and I
just didnt check properly what was going on. I mean, I've been messy, and
your answer would make sense. I'll trace my steps again in the morning.
It's great to start seeing what could have actually happened thru the fog
of my cluelessness though.


2013/3/12 Steven Kryskalla <skryskalla@gmail.com>

> On Tue, Mar 12, 2013 at 3:37 PM, Mario Campos <mariocampos0001@gmail.com>
> wrote:
> > The question now is...why did it work on my local environment  but not in
> > production?its not like the character limit works differently is it?
>
> Are you using SQLite in development? SQLite does not enforce some
> constraints:
>
> http://www.sqlite.org/datatype3.html
>
> "Note that numeric arguments in parentheses that following the type
> name (ex: "VARCHAR(255)") are ignored by SQLite - SQLite does not
> impose any length restrictions (other than the large global
> SQLITE_MAX_LENGTH limit) on the length of strings, BLOBs or numeric
> values."
>
> -steve
>



-- 

\\\\\\\\\\

Mario Campos Castellano | Motion Design | Compositing | etc

portfolio :: mario.campote.com

+49 1775318616
+34 600 203 395