HTTP 500 when cloning newly created mercurial repository

Issue #635 resolved
Paweł Widera created an issue

I'm running 1.4.4. I've recently changed the nginx configuration for rhodecode to use a subdomain instead of url prefix and to use https exclusively. Since then, I can't clone a mercurial repository (cloning git works).

The result of hg --traceback clone is HTTP 500 error from urllib:

File "/usr/lib/python2.7/", line 518, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 500: Internal Server Error

In the rhodecode logs there are just two requests. First triggers authorisation and the second one fails with HTTP 500.

[pid: 13228|app: 0|req: 1/1] () {32 vars in 490 bytes} [Sat Nov  3 23:01:18 2012] GET /reponame?cmd=capabilities => generated 260 bytes in 64 msecs (HTTP/1.1 401) 2 headers in 127 bytes (1 switches on core 0)
[pid: 13228|app: 0|req: 2/2] () {34 vars in 538 bytes} [Sat Nov  3 23:01:18 2012] GET /reponame?cmd=capabilities => generated 114 bytes in 179 msecs (HTTP/1.1 500) 2 headers in 100 bytes (1 switches on core 0)

Nginx log doesn't show anything very useful either: - - [03/Nov/2012:23:01:18 +0000] "GET /netvis?cmd=capabilities HTTP/1.1" 401 272 "-" "mercurial/proto-1.0" - user [03/Nov/2012:23:01:18 +0000] "GET HTTP/1.1" 500 114 "-" "mercurial/proto-1.0"

I'm not sure how can I investigate that further. How to get more detailed log? Where should I look first for the code causing this?

Comments (4)

  1. Marcin Kuzminski repo owner

    Please check rhodecode log for exceptions, it should be stored there somewhere.

  2. Paweł Widera reporter

    That's the problem. My log does not show anything usefull (except the 2 request I've already quoted). How should I setup the loggers in production.ini to see DEBUG strings from e.g. rhodecode.lib.utils or rhodecode.lib.middleware.simplehg?

    I've noticed that if I run rhodecode on localhost using paster I can see much more detailed log. But when I run it as uwsgi application, this information does not land in the log.

  3. Paweł Widera reporter

    OK, I've found the source of the logging problem. Paste loggers are ignored by uwsgi unless --paste-logged option is specified and that is only present with new uwsgi 1.2.

    So now I can see the full log:

    2012-11-05 02:11:42.671 ERROR [rhodecode.lib.middleware.simplehg] Traceback (most recent call last):
    File "/opt/rhodecode-virtenv/local/lib/python2.7/site-packages/rhodecode/lib/middleware/", line 197, in _handle_request
      return app(environ, start_response)
    File "/opt/rhodecode-virtenv/local/lib/python2.7/site-packages/mercurial/hgweb/", line 92, in __call__
      return self.run_wsgi(req)
    File "/opt/rhodecode-virtenv/local/lib/python2.7/site-packages/mercurial/hgweb/", line 101, in run_wsgi
      req.url = req.env['SCRIPT_NAME']
    KeyError: 'SCRIPT_NAME'

    I had SCRIPT_NAME set previously in nginx to make the url prefix work. As I'm using a subdomain now, I assumed it is not needed. Turns out hgweb expects it in the environment. I'm not sure if rhodecode.lib.middleware.simplehg should be setting it or not, but the following nginx configuration works fine:

    root /opt/rhodecode-virtenv/lib/python2.7/site-packages/rhodecode/public;
    location / {
      try_files $uri $uri/index.html @rhodecode;
    location @rhodecode {
      include uwsgi_params;
      uwsgi_pass unix:///run/uwsgi/app/rhodecode/socket;
      uwsgi_param SCRIPT_NAME "";
  4. Marcin Kuzminski repo owner

    Imho rhodecode shouldn't fix the SCRIPT_NAME. And it's good to know when using uwsgi, you actually have to set it. Closing

  5. Log in to comment