1
votes

I followed the steps mentioned in https://developers.openshift.com/en/python-flask.html to create a sample flask application.

When I am trying to run wsgi.py on my local mac machine. I am getting the following error.

Traceback (most recent call last):
  File "wsgi.py", line 24, in <module>
    httpd = make_server('localhost', 10000, application)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/simple_server.py",

line 144, in make_server server = server_class((host, port), handler_class) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 419, in init self.server_bind() File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/simple_server.py", line 48, in server_bind HTTPServer.server_bind(self) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/BaseHTTPServer.py", line 108, in server_bind SocketServer.TCPServer.server_bind(self) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 430, in server_bind self.socket.bind(self.server_address) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 224, in meth return getattr(self._sock,name)(*args) socket.gaierror: [Errno 8] nodename nor servname provided, or not known

1
Can you please also show your code that is causing the error? My suspicion is you are passing 'localhost' and 10000 as separate parameters as opposed to a tuple ('localhost', 10000) as expected, but can't say so without your actual code that's causing this exceptiongabhijit
if name == 'main': from wsgiref.simple_server import make_server httpd = make_server('localhost', 8051, application) httpd.serve_forever()Abhishek
As you found the lines to create httpd object and run it should only be run on your local machine and should be guarded by check of __name__ being __main__. When deploying as a wsgi.py file to OpenShift, it will run under mod_wsgi and all it wants is that there is a WSGI application entry point in the file called application. You should not start your own WSGI server if using wsgi.py.Graham Dumpleton
Please take a look at this documentation developers.openshift.com/en/python-flask.html . I am using the same code.Abhishek
Sorry, confusion on my part. I thought you were getting this on OpenShift. Didn't see that you said on your own machine. Try changing 'localhost' to an empty string instead. I have seen in some situations that MacOS X doesn't like being told to bind to 'localhost'.Graham Dumpleton

1 Answers

1
votes

Problem for me was using a non-standard port. Had to define my port separately from the host.

    self.config = {
        'user': 'root',
        'password': 'root',
        'host': '127.0.0.1',
        'port': 8889,
        'database': 'ET_Toolbox',
        'charset': 'utf8'
    }