9

After updating from 1.7.5 (where everything worked fine) I'm getting a HTTP Error 403: Forbidden when trying to open any sites via localhost. Strange thing is I have pretty much the same setup at home as here at work and everything works there... Might be an issue with proxy server we're using at work, since that's the only difference I can think of? Here's the error log I'm getting, so if anyone knows what's going on please help (;

Traceback (most recent call last):
  File "U:\Dev\GAE\lib\cherrypy\cherrypy\wsgiserver\wsgiserver2.py", line 1302, in communicate
    req.respond()
  File "U:\Dev\GAE\lib\cherrypy\cherrypy\wsgiserver\wsgiserver2.py", line 831, in respond
    self.server.gateway(self).respond()
  File "U:\Dev\GAE\lib\cherrypy\cherrypy\wsgiserver\wsgiserver2.py", line 2115, in respond
    response = self.req.server.wsgi_app(self.env, self.start_response)
  File "U:\Dev\GAE\google\appengine\tools\devappserver2\wsgi_server.py", line 246, in __call__
    return app(environ, start_response)
  File "U:\Dev\GAE\google\appengine\tools\devappserver2\request_rewriter.py", line 311, in _rewriter_middleware
    response_body = iter(application(environ, wrapped_start_response))
  File "U:\Dev\GAE\google\appengine\tools\devappserver2\python\request_handler.py", line 89, in __call__
    self._flush_logs(response.get('logs', []))
  File "U:\Dev\GAE\google\appengine\tools\devappserver2\python\request_handler.py", line 220, in _flush_logs
    apiproxy_stub_map.MakeSyncCall('logservice', 'Flush', request, response)
  File "U:\Dev\GAE\google\appengine\api\apiproxy_stub_map.py", line 94, in MakeSyncCall
    return stubmap.MakeSyncCall(service, call, request, response)
  File "U:\Dev\GAE\google\appengine\api\apiproxy_stub_map.py", line 320, in MakeSyncCall
    rpc.CheckSuccess()
  File "U:\Dev\GAE\google\appengine\api\apiproxy_rpc.py", line 156, in _WaitImpl
    self.request, self.response)
  File "U:\Dev\GAE\google\appengine\ext\remote_api\remote_api_stub.py", line 200, in MakeSyncCall
    self._MakeRealSyncCall(service, call, request, response)
  File "U:\Dev\GAE\google\appengine\ext\remote_api\remote_api_stub.py", line 226, in _MakeRealSyncCall
    encoded_response = self._server.Send(self._path, encoded_request)
  File "U:\Dev\GAE\google\appengine\tools\appengine_rpc.py", line 393, in Send
    f = self.opener.open(req)
  File "U:\Dev\Python\lib\urllib2.py", line 410, in open
    response = meth(req, response)
  File "U:\Dev\Python\lib\urllib2.py", line 523, in http_response
    'http', request, response, code, msg, hdrs)
  File "U:\Dev\Python\lib\urllib2.py", line 448, in error
    return self._call_chain(*args)
  File "U:\Dev\Python\lib\urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "U:\Dev\Python\lib\urllib2.py", line 531, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 403: Forbidden
INFO     2013-04-19 12:28:52,576 server.py:561] default: "GET / HTTP/1.1" 500 -
INFO     2013-04-19 12:28:52,619 server.py:561] default: "GET /favicon.ico HTTP/1.1" 304 -

Also, the launcher throws an error when closing:

Traceback (most recent call last):
  File "launcher\mainframe.pyc", line 327, in OnStop
  File "launcher\taskcontroller.pyc", line 167, in Stop
  File "launcher\dev_appserver_task_thread.pyc", line 82, in stop
  File "launcher\taskthread.pyc", line 107, in stop
  File "launcher\platform.pyc", line 397, in KillProcess
pywintypes.error: (5, 'TerminateProcess', 'Access is denied.')
Sasxa
  • 40,334
  • 16
  • 88
  • 102
  • check file permissions – emcpow2 Apr 19 '13 at 11:10
  • that didn't help.. all files and folder have admin and system full access permission. – Sasxa Apr 22 '13 at 06:14
  • 1
    I've tried all sorts of things, but nothing seams to work. I've installed Python and GAE on different disks, tried both 64bit and 32bit versions, checked file permissions... For now, I've installed GAE 1.7.5 and my projects work again, but it would be nice if someone had an idea how to make 1.7.7 work (: – Sasxa Apr 22 '13 at 07:34
  • 1
    A friend got the same error while trying to access localhost. He was also using a proxy. Downgrading to 1.7.5 worked for him, too. – Anubhav C May 01 '13 at 15:17
  • Just tried 1.8.0 and still not working... – Sasxa May 20 '13 at 05:49
  • I got that same issue here. 1.8.0 has problems. I can't even run the appengine selfgenerated webapp2 skeleton :/ – Bijan May 23 '13 at 12:31
  • Is it possible your work has a website on localhost? Try changing the port or disconnecting from your work's network. – natehome Jun 20 '13 at 20:40
  • Try upgrading to the 1.7.6 SDK and see if you encounter the same issue. Reason being, with the 1.7.6 SDK they released the new 'dev_appserver', maybe something there is causing the issue. – Tombatron Jul 20 '13 at 12:36
  • Have you tried launching your app from a command line with Administrator privileges? – Tombatron Jul 28 '13 at 18:43
  • adding executable permission to the folder containing the required files should work – scottydelta Jul 28 '13 at 20:20

3 Answers3

4

I had this very same issue with my MacOSX when using a proxy server using Google App Engine Launcher 1.8.6. Apparently there's an issue with "proxy_bypass" on "urllib2.py".

There are two possible solutions:

  1. Downgrade to 1.7.5, but, who wants to downgrade?
  2. Edit "[GAE Instalattion path]/google/appengine/tools/appengine_rpc.py" and look for the line that says

    opener.add_handler(fancy_urllib.FancyProxyHandler())

In my computer it was line 578, and then put a hash (#) at the beginning of the line, like this:

`#opener.add_handler(fancy_urllib.FancyProxyHandler())`

Save the file, stop and then restart your application. Now dev_appserver.py shouldn't try to use any proxy server at all.

If your application uses any external resources like a SOAP Webservice or something like that and you can't reach the server without the proxy server, then you'll have to downgrade. Please keep in mind that external javascript files (like facebook SDK or similar) are loaded from your browser, not from your application.

Since I'm not using any external REST or SOAP services it worked for me!

Hopefully it will work for you as well.

erickthered
  • 901
  • 8
  • 14
1

Try either: -Accessing it through a different proxy. I.E a . proxy within a proxy -Accessing it through your local IP i.e 192.168.1.1

Vogon Jeltz
  • 1,166
  • 1
  • 14
  • 31
0

I faced the same issue with version 1.9.5. Seems that the API proxy is sending some RPCs to the proxy server, which are then being rejected with HTTP 403 (since proxy servers are generally configured to reject connection attempts to arbitrary ports). In my case I was using the urlfetch module in my app to access external web pages, so disabling the proxy server was not a choice for me.

This is how I worked around the issue some time back (most probably it was based on comments found under this issue, but I cannot remember the exact sources).

NOTE:

  • For this approach to work, you'll have to know the hostname/IP address and default port of your proxy server, and change them appropriately in the code if you happen to connect to a different proxy server.
  • When you are not behind the proxy server, you will have to revert the applied changes in order to return to a working state (if you want internet access inside your app).

Here it goes:

  1. Disable proxy settings for the Python (Google App Engine Launcher) environment in some way. (In my case it was easy since I was launching the dev_appserver.py from a Terminal shell (on Linux), and the unset http_proxy and unset https_proxy commands did the trick.)

  2. Edit {App Engine SDK root}/google/appengine/api/urlfetch_stub.py. Find the code block

    if _CONNECTION_SUPPORTS_TIMEOUT:
        connection = connection_class(host, timeout=deadline)
    else:
        connection = connection_class(host)
    

    (lines 376-379 in my case) and replace it with:

    if _CONNECTION_SUPPORTS_TIMEOUT:
        if host[:9] == 'localhost' or host[:9] == '127.0.0.1':
            connection = connection_class(host, timeout=deadline)
        else:
            connection = connection_class('your_proxy_host_goes_here', your_proxy_port_number_goes_here, timeout=deadline)
    else:
        if host[:9] == 'localhost' or host[:9] == '127.0.0.1':
            connection = connection_class(host)
        else:
            connection = connection_class('your_proxy_host_goes_here', your_proxy_port_number_goes_here)
    

    replacing the placeholders your_proxy_host_goes_here and your_proxy_port_number_goes_here with appropriate values.

    (I believe this code can be written more elegantly, though... any Python geeks out there? :) )

  3. In my case, I also had to delete the existing compiled file urlfetch_stub.pyc (located in the same directory as urlfetch_stub.py) because the SDK didn't seem to pick up the changes until I did so.

Now you can use dev_appserver to launch your app, and use urlfetch-backed services within the app, free from HTTP 403 errors.

Janaka Bandara
  • 1,024
  • 1
  • 12
  • 27