Gitlab error “fatal: The remote end hung up unexpectedly” Again

Gitlab error “fatal: The remote end hung up unexpectedly” Again

Category : How-to

Get Social!

gitlabI previously wrote in this blog post about how to fix an error with Gitlab. The error was presented when using the  git push command with a remote repository that uses the Gitlabs HTTP protocol and not the SSH protocol.

The following error was presented in the Git client when using the git push command:

git push -u origin master
Counting objects: 556, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (539/539), done.
efrror: RPC failed; result=22, HTTP code = 413367.00 KiB/s
atal: The remote end hung up unexpectedly
Writing objects: 100% (556/556), 1.45 MiB | 367.00 KiB/s, done.
Total 556 (delta 282), reused 0 (delta 0)
fatal: The remote end hung up unexpectedly
Everything up-to-date

It seems that the issue is Nginx, Gitlab’s HTTP server, is not configured to receive large amounts of data. We need to specify the attribute client_max_body_size in Gitlab’s Nginx configuration file and specify the maximum amount of data Nginx will accept.

Open the configuration file and find the line location @gitlab.

vi /etc/nginx/sites-available/gitlab

Add the client_max_body_size attribute and specify the size value to use.

client_max_body_size 20M

The M stands for megabyte – you can also use G for gigabytes.

If the size of your git push ever exceeds the above value, you will have to either increase the size further or reduce your git commit sizes.

Your completed /etc/nginx/sites-available/gitlab file should look like the below example which has a 20MB upload limit.

upstream gitlab {
  server unix:/home/git/gitlab/tmp/sockets/gitlab.socket;
}

server {
  listen *:80 default_server;         # e.g., listen 192.168.1.1:80; In most cases *:80 is a good idea
  server_name YOUR_SERVER_FQDN;     # e.g., server_name source.example.com;
  server_tokens off;     # don't show the version number, a security best practice
  root /home/git/gitlab/public;

  # Increase this if you want to upload large attachments
  # Or if you want to accept large git objects over http
  client_max_body_size 20m;

  # individual nginx logs for this gitlab vhost
  access_log  /var/log/nginx/gitlab_access.log;
  error_log   /var/log/nginx/gitlab_error.log;

  location / {
    # serve static files from defined root folder;.
    # @gitlab is a named location for the upstream fallback, see below
    try_files $uri $uri/index.html $uri.html @gitlab;
  }

  # if a file, which is not found in the root folder is requested,
  # then the proxy pass the request to the upsteam (gitlab unicorn)
  location @gitlab {
    proxy_read_timeout 300; # Some requests take more than 30 seconds.
    proxy_connect_timeout 300; # Some requests take more than 30 seconds.
    proxy_redirect     off;

    proxy_set_header   X-Forwarded-Proto $scheme;
    proxy_set_header   Host              $http_host;
    proxy_set_header   X-Real-IP         $remote_addr;
    proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;

    proxy_pass http://gitlab;
  }

  error_page 502 /502.html;
}

 


12 Comments

Sytse Sijbrandij

10-Mar-2014 at 8:11 am

Thanks for the article, we’ll change the default push size.

Sytse Sijbrandij

10-Mar-2014 at 8:13 am

Thanks for this article, we’ll increase the default in GitLab to 20MB in version 6.7

    james.coyle

    10-Mar-2014 at 12:54 pm

    That would be great – the current default is a little small for most projects today.

    Thanks!

Phil Ryan

30-May-2014 at 5:16 am

The default location for the config files is different with the Gitlab Omnibus deployments…. to

/var/opt/gitlab/nginx/etc

and the relevant gitlab config file is gitlab-http.conf.

Also, in passing, the default size has changed to 250MB (written as 250m in the config file).

Jitendra

22-Jul-2014 at 9:33 am

Hello
I am getting same error in windows env but not able to find
vi /etc/nginx/sites-available/gitlab
file to update size can please let me know
thanks
jitendra

    james.coyle

    22-Jul-2014 at 11:11 am

    What other files do you have in that path?

raghdajd

9-Mar-2018 at 11:05 am

The remote end hung up unexpectedly i have the same problem but when i run the jobs in gitlab what i should do?

    James Coyle

    9-Mar-2018 at 11:11 am

    What jobs?

      raghdajd

      9-Mar-2018 at 11:17 am

      Running with gitlab-runner 10.4.0 (857480b6)
      on shared-runner1 (116966aa)
      Using Shell executor…
      Running on gitlab…
      Skipping Git repository setup
      Skippping Git checkout
      Skipping Git submodules setup
      $ eval $(ssh-agent -s)
      Agent pid 9178
      $ ssh-add <(echo "$SSH_PRIVATE_KEY")
      Identity added: /dev/fd/63 (/dev/fd/63)
      $ cd ~
      $ /home/gitlab-runner/.composer/vendor/laravel/envoy/envoy run deploy
      [[email protected]]: Cloning repository: releases_dir: repository: new_release_dir: app_dir: release:
      [[email protected]]: Cloning into '/home/gitlab/releases/20180309103049'…
      [[email protected]]: ssh: connect to host 10.10.10.176 port 22: Connection timed out
      [[email protected]]: fatal: The remote end hung up unexpectedly
      [✗] This task did not complete successfully on one of your servers.
      ERROR: Job failed: exit status 1
      when i execute my project manuel

        James Coyle

        9-Mar-2018 at 11:19 am

        This is the part that you need to focus on:
        ssh: connect to host 10.10.10.176 port 22: Connection timed out

        Your client can’t reach the server on that IP and port.

          raghdajd

          9-Mar-2018 at 11:22 am

          is not about the domain name? because i don’t have it

          raghdajd

          12-Mar-2018 at 11:17 am

          what is the solution to correct it ? and thanks for helping me

Leave a Reply

Visit our advertisers

Quick Poll

What type of VPN protocol do you use?

Visit our advertisers