GITLAB ERROR “FATAL: THE REMOTE END HUNG UP UNEXPECTEDLY”

If you are setting up your gitlab behind an apache server as described on my previous article, you will soon find out that you cannot push up your code into your gitlab and gitlab will throw you the following error

➜  test git:(master) ✗ git push -u origin master
Counting objects: 300, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (290/290), done.
Writing objects: 100% (300/300), 19.19 MiB | 3.83 MiB/s, done.
Total 300 (delta 14), reused 0 (delta 0)
error: RPC failed; result=22, HTTP code = 502
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
Everything up-to-date

However, if you try to push a single file change, you can safely push the code without getting any kind of annoying errors.

Solution

In order for you to push your code into your gitlab apache setup you will need to do 2 things.

Firstly you will need to run the below code on your client side (your computer!)

git config http.postBuffer 104857600

And the second steps you will need to do is to increase the timeout on gitlab! On the server, open the file unicore.rb

vim /home/git/gitlab/config/unicorn.rb

and look for the line

 38 # NOTICE: git push over http depends on this value.
 39 # If you want be able to push huge amount of data to git repository over http
 40 # you will have to increase this value too.
 41 #
 42 # Example of output if you try to push 1GB repo to GitLab over http.
 43 #   -> git push http://gitlab.... master
 44 #
 45 #   error: RPC failed; result=18, HTTP code = 200
 46 #   fatal: The remote end hung up unexpectedly
 47 #   fatal: The remote end hung up unexpectedly
 48 #
 49 # For more information see http://stackoverflow.com/a/21682112/752049
 50 #
 51 timeout 30

at line 30, you will see that you will need to change this number to something bigger, for my case, i changed it to 3600 (1 hour)

 38 # NOTICE: git push over http depends on this value.
 39 # If you want be able to push huge amount of data to git repository over http
 40 # you will have to increase this value too.
 41 #
 42 # Example of output if you try to push 1GB repo to GitLab over http.
 43 #   -> git push http://gitlab.... master
 44 #
 45 #   error: RPC failed; result=18, HTTP code = 200
 46 #   fatal: The remote end hung up unexpectedly
 47 #   fatal: The remote end hung up unexpectedly
 48 #
 49 # For more information see http://stackoverflow.com/a/21682112/752049
 50 #
 51 timeout 3600

after you have updated this value, you will need to restart gitlab!

root@monitor [/etc/httpd/conf]# service gitlab restart
Stopping unicorn:                                          [  OK  ]
Stopping sidekiq:                                          [  OK  ]
Starting unicorn:                                          [  OK  ]
Starting sidekiq:                                          [  OK  ]

Once you restarted gitlab, try to push your code again, you should be getting this

➜  test git:(master) ✗ git push -u origin master
Counting objects: 300, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (290/290), done.
Writing objects: 100% (300/300), 19.19 MiB | 5.29 MiB/s, done.
Total 300 (delta 14), reused 0 (delta 0)
To http://git.test.com/claylua/test.git
 * [new branch]      master -> master

don't you just hate apache when everyone is using nginx for gitlab? haha..

*************************************** UPDATE ********************************

*shy* i'm also using nginx now lol for reverse proxy... if everything above doesn't work, go to your nginx configuration and adjust your client_max_body_size

http {
    # ...
    client_max_body_size 16M;
    # ...

increasing this will allow your data to be send over to your server safely!