Git ошибка 502

My project size is 1,63 GB (Magento Project)
I had followed this tutorial

when I do this command : git push -u origin master , it is starting to write objects and after that I getting this error in git console:

error: RPC failed, result=22, HTTP code = 502
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly

What should I do to make this work ?

The result of the git remote -v is :
enter image description here

Kara's user avatar

Kara

6,12516 gold badges50 silver badges57 bronze badges

asked Jun 20, 2014 at 8:19

Attila Naghi's user avatar

Attila NaghiAttila Naghi

2,5556 gold badges37 silver badges59 bronze badges

13

The remote end hangs up because the pack size you are trying to transmit exceeds the maximum HTTP post size. Try to limit this pack size with

git config --local http.postBuffer 157286400

to 150MB.

answered May 1, 2015 at 5:59

user1978011's user avatar

1

I got this problem when I had proxy set, but actually did not need proxy.

To fix:

git config --global --unset http.proxy
git config --global --unset https.proxy

answered Jan 5, 2016 at 13:39

Jaanus's user avatar

JaanusJaanus

16.2k49 gold badges147 silver badges202 bronze badges

0

I faced similar issue after I added HTTP_PROXY and HTTPS_PROXY environment variables to make other things work. I was unable to use our internal git repos. There is a way to fix it to fix it:
You can add proxy variables with empty values to git using git config --global --edit:

[http]
    proxy = 
[https]
    proxy = 

Or using commands:

git config --global --add http.proxy ""
git config --global --add https.proxy ""

answered Dec 16, 2021 at 7:53

DJ-Glock's user avatar

DJ-GlockDJ-Glock

1,2772 gold badges12 silver badges39 bronze badges

0

first increase size

# git config --global http.postBuffer 1048576000                                   
git config --global http.postBuffer 500M
git config --global http.maxRequestBuffer 100M
git config --global core.compression 0

to check size

git config --get http.postBuffer

then open server terminal

su
nano /etc/gitlab/gitlab.rb 

#edit this line
unicorn['worker_timeout'] = '4000'

#running
gitlab-ctl reconfigure

#for any case restart machine

answered Jan 11, 2021 at 21:20

Pit's user avatar

PitPit

4053 silver badges11 bronze badges

I had similar problem when I switched from proxy connection (via CNTLM) to direct.
The solution is to remove this line from http section in file c:\Users\.gitconfig:

proxy = localhost:3128

answered Apr 27, 2016 at 23:55

Khizhny Andrey's user avatar

In my case I got the same error (HTTP 502 Bad gateway curl 22) when I created a git repository on a server under root user. Of course in this situation fcgiwrap and git-http-backend couldn’t receive data from a client under www-data user. So after re-initialization of a server repository under www-data user the error is gone. Hope it helps someone.

answered May 17, 2017 at 5:05

AVKurov's user avatar

AVKurovAVKurov

1561 gold badge2 silver badges6 bronze badges

2

I was seeing the same error and none of these solutions worked. It was a stupid mistake but I thought I would add it in case anyone else runs into it. I forgot the «.git» on the end of the URL when setting the remote origin.

answered Dec 13, 2019 at 18:52

mybodycravesbutterygoodness's user avatar

1

if you are experiencing this issue on source tree , then do the following :

  1. Open preferences ( on Mac ) or settings ( in windows )
  2. click on ‘Git’ tab.
  3. Find «git version». under git version click on ‘reset to Embedded git’ button and then click back on ‘Use System Git’ button. ( this setting is for Mac OS , if you are using windows , find something similar there. ) enter image description here

see image

answered Oct 11, 2018 at 18:57

YogiAR's user avatar

YogiARYogiAR

2,20723 silver badges44 bronze badges

My HTTP_PROXY and HTTPS_PROXY were setup in environment variable(s) for one project. So, removing this from environment variable(s) helped me sort the issue.

Adriaan's user avatar

Adriaan

17.7k7 gold badges42 silver badges75 bronze badges

answered Jan 19 at 9:45

mitesh keswani's user avatar

The error «The requested URL returned error 502» is a common issue faced by users when using Git in a corporate environment. This error occurs when the Git client is unable to access the requested URL due to network restrictions, firewalls, or incorrect proxy configurations. In such cases, users might be unable to clone, fetch, or push changes to remote repositories. To resolve this error, there are several methods that can be tried, including updating the Git configuration, troubleshooting proxy settings, and bypassing firewalls.

Method 1: Updating Git Configuration

To fix the error «The requested URL returned error 502» in Git, you can try updating Git configuration by following these steps:

  1. Open Git Bash or your terminal and type the following command to check the current Git configuration:

  2. Look for the «http.proxy» setting. If it is set to a proxy server, you need to update it to your corporate proxy server. Type the following command to update the proxy setting:

    git config --global http.proxy http://corporate-proxy-server:port

    Replace «corporate-proxy-server» and «port» with your corporate proxy server and port number.

  3. If your corporate proxy requires authentication, you need to add your username and password to the Git configuration. Type the following command to add your username:

    git config --global http.proxyUsername your-username

    Replace «your-username» with your actual username.

  4. Type the following command to add your password:

    git config --global http.proxyPassword your-password

    Replace «your-password» with your actual password.

  5. Finally, type the following command to verify the updated Git configuration:

    Look for the «http.proxy» setting and make sure it is set to your corporate proxy server.

With these steps, you should be able to fix the error «The requested URL returned error 502» in Git by updating Git configuration.

Method 2: Troubleshooting Proxy Settings

To troubleshoot proxy settings in Git, follow these steps:

  1. Check if the proxy settings are configured correctly by running the following command in the terminal:

    git config --global http.proxy

    If the output is empty, it means that Git is not using a proxy. If there is a proxy URL, note it down for later use.

  2. If the proxy URL is not set, you can set it using the following command:

    git config --global http.proxy http://proxy-url:port

    Replace proxy-url and port with the URL and port number of your proxy server.

  3. If the proxy URL is set correctly, try disabling SSL verification by running the following command:

    git config --global http.sslVerify false

    This will bypass SSL verification and may resolve the 502 error.

  4. If the above steps do not work, try setting the http.postBuffer to a higher value by running the following command:

    git config --global http.postBuffer 524288000

    This will increase the buffer size and may help resolve the error.

  5. If none of the above steps work, try setting the http.version to HTTP/1.1 by running the following command:

    git config --global http.version HTTP/1.1

    This will force Git to use HTTP/1.1 instead of the default HTTP/1.0 and may help resolve the error.

By following these steps, you should be able to troubleshoot proxy settings and resolve the 502 error in Git.

Method 3: Bypassing Firewalls

If you are facing the error «Git: how to fix The requested URL returned error 502, corporate?» while trying to push or pull code from a Git repository behind a corporate firewall, you can try bypassing the firewall by using a proxy server. Here’s how you can do it:

  1. Set up a proxy server: You can use a free proxy server or set up your own proxy server. For example, you can use the following command to set up a SOCKS proxy server using SSH:

    ssh -D 8080 user@proxy-server

    This will create a local SOCKS proxy server listening on port 8080 that forwards all traffic through the proxy server.

  2. Configure Git to use the proxy server: You can configure Git to use the proxy server by setting the http.proxy and https.proxy Git configuration variables. For example, you can use the following commands to configure Git to use the SOCKS proxy server:

    git config --global http.proxy socks5://localhost:8080
    git config --global https.proxy socks5://localhost:8080

    This will configure Git to use the SOCKS proxy server running on localhost port 8080 for both HTTP and HTTPS connections.

  3. Test the Git connection: You can test the Git connection by running the following command:

    git ls-remote https://github.com/username/repo.git

    This will list the remote Git references for the repository username/repo.git on GitHub. If the command succeeds, you should be able to push and pull code from the repository without getting the error «Git: how to fix The requested URL returned error 502, corporate?».

That’s it! By using a proxy server, you can bypass the corporate firewall and access Git repositories that are otherwise blocked.

Method 4: Switching to SSH Instead of HTTPS

To fix the error «The requested URL returned error 502, corporate» in Git, you can switch to using SSH instead of HTTPS. Here are the steps to do so:

  1. Generate an SSH key pair if you haven’t already done so. You can do this using the following command:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
  1. Add your public SSH key to your Git account. You can copy the contents of your public key file (usually ~/.ssh/id_rsa.pub) and paste it into your Git account settings.

  2. Update your Git remote URLs to use SSH instead of HTTPS. You can do this using the following command:

git remote set-url origin git@github.com:username/repo.git

Replace username with your Git username and repo with the name of your repository.

  1. Test your SSH connection by running the following command:

You should see a message that says «Hi username! You’ve successfully authenticated, but GitHub does not provide shell access.»

That’s it! You should now be able to push and pull from your Git repository using SSH instead of HTTPS.

Note: If you’re using a different Git hosting service, the steps may be slightly different. Check their documentation for more information.

I have been running into a very strange issue with a git repo where I am able to edit and update an existing file (css, html, js, xml) and do a normal push BUT if I add new files to the repo or REPLACE existing files, I get the following error when I would usually input my credentials on a successful push:

error: RPC failed; result=22, HTTP code = 502
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly

I have read over the many posts on this issue and have run:

git config http.postBuffer 524288000

from the clone directory.

I am running: git version 1.8.3.2

$ git remote -v  outputs the following
origin http://[redacted]/git/TestProgram.git (fetch)
origin http://[redacted]/git/TestProgram.git (push)

On the server log, I see a Bad Gateway error but I KNOW that the git repo exists and is correct being that I’m able to clone it and update files — just not add or replace files in the clone. I’m leaning towards this being a disk write permissions issue. Has anyone run into anything similar — does this assessment sound valid?

Any ideas would be welcome, as I’ve been bashing my face off of this all week.

GitLab Forum

Loading

Ставлю GitLab на свой сайт, в поддомен, за своим собственным nginx, проблема в том, что не могу клонировать проект из GitLab’а, выдает ошибку 502.

Подробнее:
VPS, чистая Ubunta 18.04 LTS, 2 ядра, ОЗУ 4 Гб, диск 25 Гб;
1. ставлю nginx, потом Passenger (без Passenger не удастся переключить GitLab со встроенного на внешний nginx);
2. ставлю GitLab в поддомен;
3. отключаю nginx, встроенный в GitLab, переключаюсь на внешний nginx.

Все три пункта делаю в соответствии с документацией на GitLab.

Сразу после этого GitLab не работает, по логам нахожу ошибки, добавляю:
даю права пользователю git на /var/opt/gitlab;
инсталлирую ruby-dev && nodejs.

После этого в поддомене появляется GitLab, определяю пароль администратора, в целом web-версия выглядит рабочей.

Но — не могу клонировать проект из GitLab’а, выдает ошибку 502:
$ git clone https://git.tradercad.com/root/tock.git
Cloning into ‘tock’…
remote: GitLab is not responding
fatal: unable to access ‘https://git.tradercad.com/root/tock.git/’: The requested URL returned error: 502

Что странно, при запросе git clone в логах встроенного nginx по адресу var/log/gitlab/nginx/gitlab_access.log появляется запись:
81.30.208.16 — — [03/May/2021:13:51:42 +0300] «GET /root/tock.git/info/refs?service=git-upload-pack HTTP/1.1» 502 24 «-» «git/2.29.2.windows.2»

и при открытии в браузере страницы git.tradercad.com var/log/gitlab/nginx/gitlab_access.log появляется запись:
81.30.208.16 — — [03/May/2021:13:56:02 +0300] «GET /users/sign_in HTTP/1.1» 200 15487 «-» «Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36»

в то время как в логах «нормального» nginx по адресу var/log/nginx/access.log и var/log/nginx/error.log ничего, пусто.

Может быть, nginx, встроенный в GitLab, отключен не до конца?

Понравилась статья? Поделить с друзьями:
  • Git ошибка 500
  • Git ошибка 401
  • Git push ошибка 403
  • Git ошибка 128
  • Git push ошибка авторизации