Skip to content


Fix for the Tornado server #38

wants to merge 1 commit into from

2 participants


Hi Armin,

I fixed a small bug when we try to use nginx with Tornado and Flask.

The value of SERVER_PORT is an integer value and not a String, and we have a traceback, because it can concat a string with an integer.



PS: I think my commit message is wrong.


This is a bug in tornado and should be fixed there. I will not change Werkzeug in that regard because it opens a can of worms and there might be other places where SERVER_PORT is used.

This problem can easily be worked around with a small WSGI middleware:


I agree with you, I created a small middleware based on your code, and it works fine.

Thank you and sorry for my Pull Request.


This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 25, 2011
  1. @matrixise
Showing with 1 addition and 1 deletion.
  1. +1 −1 werkzeug/
2 werkzeug/
@@ -1097,7 +1097,7 @@ def bind_to_environ(self, environ, server_name=None, subdomain=None):
server_name = environ['SERVER_NAME']
if (environ['wsgi.url_scheme'], environ['SERVER_PORT']) not \
in (('https', '443'), ('http', '80')):
- server_name += ':' + environ['SERVER_PORT']
+ server_name += ':' + str(environ['SERVER_PORT'])
elif subdomain is None:
if 'HTTP_HOST' in environ:
wsgi_server_name = environ.get('HTTP_HOST')
Something went wrong with that request. Please try again.