4

I'm using Eclipse Java EE and when I compile and run my Google AppEngine project on localhost:8080 the browser doesn't give any correct output, but when I'm using 127.0.0.1:8080 my program runs on the browser just fine. But when I deploy my app to the google appspot then the localhost:8080 will updated and works well ( only for the instance that I deployed to the appspot ).

Why localhost:8080 won't update right and 127.0.0.1:8080 update right?

I can't use 127.0.0.1:8080 insted localhost always because when I try to get the _ah/api/explorer then 127.0.0.1:8080/_ah/api/explorer will redirect to the google apis explorer ( not to my api explorer).

What should I do to get this right?

tomrozb
  • 25,773
  • 31
  • 101
  • 122
u91
  • 254
  • 2
  • 10
  • Could be an IPv4 vs. IPv6 issue. Does your `/etc/hosts` file have IPv6 entries for `localhost`? – Asaph Jan 28 '15 at 17:42
  • nope I guess not, l1>> 127.0.0.1 localhost sandbox.dev l2>> 127.0.0.1 localhost these are the two entries that I recently added and these won't do any good either. – u91 Jan 28 '15 at 17:47

2 Answers2

2

Use the parameter :

--address=...

The host address to use for the server. You may need to set this to be able to access the development server from another computer on your network. An address of 0.0.0.0 allows both localhost access and hostname access. Default is localhost.

More on this here.

koma
  • 6,486
  • 2
  • 27
  • 53
  • I think it's related to the version, but I had to use --host=0.0.0.0, anyway, you put me on the rail ! Thanks – Laurent Apr 10 '15 at 07:41
2

I would have just added this as a comment to the accepted answer, but I don't have enough reputation points yet.

The above answer is 100% correct, but an alternative to starting it with the flag, is to edit the pom.xml. Near the bottom of mine was this. I had to uncomment the "address" line and... magic... http://localhost:8080/ started working again. Now I just wish I had those 3 hours back. :D

<plugin>
    <groupId>com.google.appengine</groupId>
    <artifactId>appengine-maven-plugin</artifactId>
    {snip}
    <configuration>
        {snip}
        <!-- Comment in the below snippet to bind to all -->
        <!-- IPs instead of just localhost -->
        <address>0.0.0.0</address>
        <port>8080</port>
        {snip}
     </configuration>
 </plugin>

Here is where I found the original. Scroll to the very bottom:

https://github.com/GoogleCloudPlatform/appengine-endpoints-helloendpoints-java-maven/blob/master/pom.xml

Cade Thacker
  • 105
  • 2
  • 9