Failed to start devlopment server — BindError: Unable to find a consistent port localhost
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 / lsof -i:8000 to make sure these ports are not taken. I also tried use a --port arg to switch to another port. I even removed the gae folder and installed a new one. -- with no luck at all. Maybe there is a obvious solution but I can't see it. Here is the Oh-My-God trace stack.. Traceback (most recent call last): File "/home/henry/software/google_appengine/dev_appserver.py", line 182, in
_run_file(__file__, globals()) File "/home/henry/software/google_appengine/dev_appserver.py", line 178, in _run_file execfile(script_path, globals_) File "/home/henry/software/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 689, in main() File "/home/henry/software/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 682, in main dev_server.start(options) File "/home/henry/software/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 653, in start apis.start() File "/home/henry/software/google_appengine/google/appengine/tools/devappserver2/api_server.py", line 152, in start super(APIServer, self).start() File "/home/henry/software/google_appengine/google/appengine/tools/devappserver2/wsgi_server.py", line 294, 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 Exception in thread Thread-4 (most likely raised during interpreter shutdown): Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner File "/usr/lib/python2.7/threading.py", line 763, in runhenry@henry-A
This can be caused by multiple entries in your hosts file for ‘localhost’.
For example in file
127.0.0.1 localhost 127.0.0.1 mymachinename localhost
if you delete all mappings but one for localhost, the problem will hopefully be resolved.
127.0.0.1 mymachinename localhost
This is a known issue and as far as I understand it will be corrected in a future release.
While I never seen that before try running it on a different port or even using a different host:
dev_appserver.py /path/to/project --port 8888 --host 127.0.0.1
Where for host add your current IP address.
Similar to what was posted, I had this issue and fixed it by altering the hosts file. The issue was with IPv6 addresses redirecting to localhost:
In my hosts file I had
127.0.0.1 localhost ::1 localhost fe80::1%lo0 localhost
And I commented out the IPv6 addresses to give
127.0.0.1 localhost #::1 localhost #fe80::1%lo0 localhost
I’m not sure this is a viable permanent solution as I imagine it’s important to have the IPv6 numerical addresses for localhost to be in the hosts file but it works for now until a proper fix is released.
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.
dev_appserver.py . --port 4000
this fixed it for me.
I solved this issue by passing an explicit api port to
dev_appserver.py path/to/project --api_port 3000
I was unable to solve the issue by editing the hosts file or passing
I didn’t identify the root cause.
In my case just restarting the terminal worked.
- Database Administration Tutorials
- Programming Tutorials & IT News
- Linux & DevOps World
- Entertainment & General News
- Games & eSport