5

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 <module>
        _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 <module>
        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

7 Answers 7

6

This can be caused by multiple entries in your hosts file for 'localhost'.

For example in file /etc/hosts:

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.

2
  • It works! I find a duplication of 127.0.0.1 localhost in my hosts, so there are two mapping on localhost. I remove one and dev-server runs now.
    – Henry.T
    May 23, 2013 at 3:13
  • it works for me also. Important! should be single entry resolve your problem bcz first I was remove only few of theme but it was not working, So as I remove all entries except one 127.0.0.1 localhost it works. Sep 8, 2013 at 12:42
3

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.

2

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.

2
  • I only have ::1 ip6-localhost ip6-loopback in hosts for IPv6, no ::1 localhost.
    – Henry.T
    May 23, 2013 at 3:19
  • I only commented out the fe80::1%lo0 line, and dev_appserver.py is much happier.
    – nop
    Dec 24, 2015 at 18:18
1

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.

1
dev_appserver.py . --port 4000

this fixed it for me.

0

I solved this issue by passing an explicit api port to dev_appserver.py:

dev_appserver.py path/to/project --api_port 3000

I was unable to solve the issue by editing the hosts file or passing --port / --host to dev_appserver.py.

I didn't identify the root cause.

0

In my case just restarting the terminal worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.