Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am posting this here, as apparently, I am unlikely to get any help at raspberry pi. Please bear with me.

I have a small problem with configuring Mercurial to work with nginx using unix sockets on raspberry pi. When accessing http://myip/hg via web browser, I get 502 Bad Gateway error and error.log displays following error:

connect() to unix:/srv/hg/mercurial.sock failed (111: Connection refused) while connecting to upstream, client: myPCIP, server: localhost, request: "GET /hg/ HTTP/1.1", upstream: "fastcgi://unix:/srv/hg/mercurial.sock:", host: "myServerIP"

I can't seem to figure out what is wrong.

Oh and here is my default web site config:

server {
        #listen   80; ## listen for ipv4; this line is default and implied
        #listen   [::]:80 default_server ipv6only=on; ## listen for ipv6

        root /usr/share/nginx/www;
        index index.html index.htm;

        # Make site accessible from http://localhost/
        server_name localhost;

        # mercurial setup
        location /hg {
                root /srv/hg/;
                auth_basic "Secure Login";
                auth_basic_user_file /srv/hg/hgusers;
                fastcgi_pass unix:/srv/hg/mercurial.sock;
                fastcgi_param SCRIPT_FILENAME /srv/hg/$fastcgi_script_name;
                fastcgi_param PATH_INFO $uri;
                fastcgi_param REMOTE_USER $remote_user;
                fastcgi_param DOCUMENT_ROOT /srv/hg/;
                include fastcgi_params;
                client_max_body_size 20M;

                fastcgi_param QUERY_STRING $query_string;
                fastcgi_param REQUEST_METHOD $request_method;
                fastcgi_param CONTENT_TYPE $content_type;
                fastcgi_param CONTENT_LENGTH $content_length;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ =404;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules

        # pass the PHP scripts to FastCGI server listening on
        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_pass php5-fpm-sock;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
                include fastcgi_params;
share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.