15 Dec 2008

I'm getting a weird Invalid Argument error while trying to hit localhost with urlfetch in the latest Google App Engine SDK.

I traced the issue to the _RetrieveURL method in /usr/local/google_appengine/google/appengine/api/urlfetch_stub.py and implemented a quick hack, adding the following at line 152:

# Aral - hack: for some reason urlfetch doesn't like localhost
# so we translate it to 127.0.0.1. This is for local testing only.
if host == 'localhost:8080':
  host = '127.0.0.1:8080'

This basically allows me to hit one instance of the local dev server from another for testing some functionality I need for the Google App Engine backup/restore solution I'm working on. Without this hack, I can't hit localhost with urlfetch at all.

I'm still not sure why this is happening. (Could appenginepatch be messing things up — it was working under AppEngineHelper... hmm?)

Add Your Comment

Spam Protection by WP-SpamFree

Weird error with urlfetch and localhost

  1. Per Google documentation overview http://code.google.com/appengine/docs/urlfetch/overview.html

    URL fetches are restricted to accessing ports 80 (http) and port 443 (https). No other ports or URL schemes are supported.

    It’s in the Things to Know About urlfetch section.

    T L Holaday