nginx uwsgi internal server error 500 - http uwsgi header: "Connection: close"

14,227

[SOLVED] uswgi was not able to resolve on python module.

I did the following and found the error, it may be useful to someone else for debugging.

Checked the log of uswgi: if you don't have, set it in the .ini file where tells uwsgi to start your app:

logto = /var/log/uwsgi/%n.log

(I refer to this tutorial in case you are new: https://www.digitalocean.com/community/tutorials/how-to-serve-flask-applications-with-uwsgi-and-nginx-on-ubuntu-14-04)

Then locate your log file in the above folder, and :

tail -f myapp.log

I found that python app was not found. After scratching my head a bit, I found the error was not in the header, but simply because I had named a backup module of my app as [name.version.py] notation (primary thing not to do in naming python modules .. uups I did it).

So it was not knowing which module to start.

As example, renamed backup as: mv oldname.version.py newname_version.py

and works again.

However, since I uploaded the backup files to the servers while the app was working correctly, and kept on working until two days ago, I understand the server went down and restarted, then not being able to which of modules resolve: how to monitor a server restart? is it normal? As you understand, I want to configure decently despite server settings is not my business and comments for a clearer understanding on how to prevent or handle error 500 (setting alarms) are much appreciated!

Share:
14,227

Related videos on Youtube

user305883
Author by

user305883

Updated on September 18, 2022

Comments

  • user305883
    user305883 over 1 year

    I am using a small server with nginx and a python flask app on aws, and uwsgi. It has already happened twice that the server went down with error 500, and no logs on behalf of nginx. I am not expert, could you please help in figuring why the following happen?

    it looks like the server 'randomly'(?) stops with this error: (I activated debug in error_log /pathtomylog/error.log debug in nginx.conf file to be able to see it):

    2015/12/02 22:05:12 [debug] 19006#0: *1 http upstream process header
    2015/12/02 22:05:12 [debug] 19006#0: *1 malloc: 0000000001D24CE0:4096
    2015/12/02 22:05:12 [debug] 19006#0: *1 recv: fd:11 104 of 4096
    2015/12/02 22:05:12 [debug] 19006#0: *1 http uwsgi status 500 "500 Internal Serv
    er Error"
    2015/12/02 22:05:12 [debug] 19006#0: *1 http uwsgi header: "Connection: close"
    2015/12/02 22:05:12 [debug] 19006#0: *1 http uwsgi header: "Content-Type: text/p
    lain"
    2015/12/02 22:05:12 [debug] 19006#0: *1 http uwsgi header done
    2015/12/02 22:05:12 [debug] 19006#0: *1 xslt filter header
    2015/12/02 22:05:12 [debug] 19006#0: *1 HTTP/1.1 500 Internal Server Error
    

    I tried to kill all the workers of uswgi. I tried to restart nginx. RAM memory looks still ok, and deactivated swapping for the sake of ElasticSearch (yes, I am using it on 1gb ram, but for the size of my index it did not complained yet).

    Could you also point to a reference on how to set up an alarm or something? Since the error happened twice without having modified by conf files neither the app, static files are served ok, the API ending point not, I thought it be related to uswgi, but cannot figure out.

    I am not an expert in server configuration and it is really a full of technical details world! Please help in districate in the jungle :)