本地服务器通过Objectify无法访问App Engine Datastore问题求助
Hey there, let's work through this warning you're hitting when running your App Engine Spring project locally in Eclipse. First, let's break down what's happening:
Apr 23, 2018 4:01:04 PM com.google.auth.oauth2.ComputeEngineCredentials runningOnComputeEngine
WARNING: Failed to detect whether we are running on Google Compute Engine.
java.net.SocketException: Network is unreachable: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java...
This warning comes from Google's OAuth2 auth library—it's trying to check if your app is running on Google Compute Engine (GCE), which it obviously isn't when you're working locally. The error happens because your local network (firewall, proxy, or restricted connection) is blocking the request to GCE's metadata endpoint used for this detection.
Here are a few practical ways to handle this:
Just ignore the warning
This is totally safe! The warning doesn't affect the functionality of your local App Engine server. Your project will run normally even with this message in the console.Disable GCE environment detection
If the warning is bugging you, you can turn off this check entirely by adding a VM argument in your Eclipse run configuration:- Open your project's Run Configuration (right-click project → Run As → Run Configurations)
- Go to the Arguments tab
- In the VM arguments box, add:
-Dcom.google.auth.oauth2.disable_gce=true - Save the configuration and restart your server—the warning should disappear.
Fix network connectivity issues
If your project needs to connect to GCP services locally, resolve the network block:- Check your local firewall settings to ensure it isn't blocking outgoing requests to
metadata.google.internal - If you're behind a proxy, configure Eclipse's network proxy correctly: go to Window → Preferences → General → Network Connections and set up your proxy details
- Try pinging
metadata.google.internalin your terminal to confirm if the endpoint is reachable from your network
- Check your local firewall settings to ensure it isn't blocking outgoing requests to
Update your Google Auth dependencies
Older versions of thegoogle-auth-library-oauth2-httplibrary might have buggy detection logic. If you're using Maven or Gradle, update this dependency to the latest stable version in your build file (pom.xml or build.gradle) to see if the issue is resolved.
内容的提问来源于stack exchange,提问作者Arun Muthuraman

