Failed to start devlopment server — BindError: Unable to find a consistent port localhost

前端 未结 7 2068
逝去的感伤
逝去的感伤 2020-12-03 23:13

Google-app-engine development server runs great yesterday, but when I try to start it today. It only shout out this Error.

I tried use lsof -i:8080 / <

相关标签:
7条回答
  • 2020-12-04 00:02

    I suppose there is a bug in the google app engine. I debuged appengine/tools/devappserver2/wsgi_server.py, and here is the facts: 1. it runs fine when internet is disconnected 2. it shows such error when internet is on.

    280 addrinfo = socket.getaddrinfo(host, port, socket.AF_UNSPEC,
    281                                     socket.SOCK_STREAM, 0, socket.AI_PASSIVE)
    

    In this piece of code, if you connect internet, addrinfo will only have the address in public internet. even you assign port and host in command line. Then you have no chance to bind this socket to localhost, since the address you bind is the public address you are using now.

    In order to solve it, I just change the code into

    280 addrinfo = socket.getaddrinfo(host, port, socket.AF_UNSPEC,
    281                                     socket.SOCK_STREAM, 1, socket.AI_PASSIVE)
    

    It works well now, I didn't check the code about socket.getaddrinfo, however, I suppose that it functions as ignoring the lookup address or not according to the integer 0 or 1.

    Btw, I am using MacOs, there could be system dependency problem as well, if this is the case, then socket package should redesign somehow.

    0 讨论(0)
提交回复
热议问题