How can I solve 'Unable to find consistent port localhost' App Engine error?

允我心安 提交于 2019-12-10 14:42:29

问题


I'm attempting to run Google App Engine just to get a hello world app up but have been failing. I'm on Windows 7 and have tried to use the GUI launcher as well as the Cygwin terminal. Having followed many different suggestions from SO forums (Failed to start devlopment server -- BindError: Unable to find a consistent port localhost) and others:

-I have edited the localhosts entry in the etc/hosts file to 127.0.0.1

-I've reinstalled the Google App Engine package

-Tried editing the .yaml and main.py files

-Tried changing the port to 9000 and 8888

-Tried explicitly specifying the host I'm launching on? (eg: --skip_sdk_update_check=yes --port=8080 --admin_port=8000 --host 127.0.0.1)

-Tried specifically allowing the app engine launcher to communicate through the firewall

Nothing has made a difference yet.

The error message reads:

"2013-07-13 16:35:05 Running command: "['C:\\Python27\\python.exe', 'C:\\Program Files (x86)\\Google\\google_appengine\\dev_appserver.py', '--skip_sdk_update_check=yes', '--port=8080', '--admin_port=8000', u'C:\\Users\\Greg\\hello-udacity']"
INFO     2013-07-13 16:35:12,631 devappserver2.py:528] Skipping SDK update check.
WARNING  2013-07-13 16:35:12,655 api_server.py:314] Could not initialize images API; you are likely missing the Python "PIL" module.
WARNING  2013-07-13 16:35:12,660 simple_search_stub.py:955] Could not read search indexes from c:\users\greg\appdata\local\temp\appengine.hello-udacity\search_indexes
Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\google_appengine\dev_appserver.py", line 182, in <module>
    _run_file(__file__, globals())
  File "C:\Program Files (x86)\Google\google_appengine\dev_appserver.py", line 178, in _run_file
    execfile(script_path, globals_)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 695, in <module>
    main()
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 688, in main
    dev_server.start(options)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\devappserver2.py", line 659, in start
    apis.start()
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\api_server.py", line 137, in start
    super(APIServer, self).start()
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\wsgi_server.py", line 298, in start
    raise BindError('Unable to find a consistent port %s' % host)
google.appengine.tools.devappserver2.wsgi_server.BindError: Unable to find a consistent port localhost
2013-07-13 16:35:12 (Process exited with code 1)"

回答1:


From the error message it appears you are explicitly passing --skip_sdk_update_check=yes --port=8080 --admin_port=8000

Have you tried specifying the host you are launching on? eg:

--skip_sdk_update_check=yes --port=8080 --admin_port=8000 --host 127.0.0.1

Another item of interest would be to temporarily kill any firewalls you have running on your machine and see if that makes a difference.




回答2:


Ran into this problem with a colleague in China with Astrall VPN running on the machine. Changed from Open mode to Stealth Mode, and this fixed the problem.




回答3:


It's probably too late, but I just ran into this same condition after updating AppEngine SDK. In the "wsgi_server.py" file edit the following line

class WsgiServer(object):
    .....
    def start(self):
        try:
           addrinfo = socket.getaddrinfo(host, port, socket.AF_UNSPEC,
                                socket.SOCK_STREAM, 0, socket.AI_PASSIVE)

to

class WsgiServer(object):
    .....
    def start(self):
        try:
           addrinfo = socket.getaddrinfo(host, port, socket.AF_UNSPEC,
                                socket.SOCK_STREAM, 1, socket.AI_PASSIVE)


来源:https://stackoverflow.com/questions/17633881/how-can-i-solve-unable-to-find-consistent-port-localhost-app-engine-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!