All,
I have an API with two endpoints built using Flask. I am using an nginx/uwsgi combo for serving and I am getting an odd error whenever I send a GET request to one of the end points. The other endpoint works just fine.
Here is the output from my uwsgi log from a get request
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1646, in request_context
return RequestContext(self, environ)
File "/usr/local/lib/python2.7/dist-packages/flask/ctx.py", line 166, in __init__
self.url_adapter = app.create_url_adapter(self.request)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in create_url_adapter
server_name=self.config['SERVER_NAME'])
File "/usr/local/lib/python2.7/dist-packages/werkzeug/routing.py", line 1196, in bind_to_environ
environ['REQUEST_METHOD'], environ.get('PATH_INFO'),
KeyError: 'REQUEST_METHOD'
And, here is the output from the nginx error log from a get request
2013/12/26 15:22:16 [error] 833#0: *9 upstream prematurely closed connection while reading response header from upstream,
client: 71.71.53.31, server: scholarly,
request: "GET /citelet/ HTTP/1.1",
upstream: "uwsgi://unix:///tmp/citelet.sock:",
host: "162.243.219.38"
I apologize for the vagueness of this question. I've set up this server several times on the same hardware, with the same libraries, and had no issues before. The error is confusing and I'm not really sure where to start looking.
Thanks in advance!
Stupid mistake. There was an error in my nginx config. It was pointing to a non-existent socket.
just for reference: I was getting the same error, and realized I'd forgotten to add
include uwsgi_params;
as in user1558914's answer.then it still wasn't working after
make restart
because I had my uwsgi restart rule, which was failing, ahead of the nginx restart. once I manually restarted nginx with/etc/init.d/nginx restart
, the KeyError ceased.