gogs: error: RPC failed; HTTP 502 curl 22 The requested URL returned error: 502 Bad Gateway
- Gogs version (or commit ref):
0.10.18.0313
- Git version:
2.11.1
- Operating system:
Ubuntu 16.04 64bits
- Database (use
[x]
):- PostgreSQL
- MySQL
- MSSQL
- SQLite
- Can you reproduce the bug at https://try.gogs.io:
- Yes (provide example URL)
- No
- Not relevant
- Log gist (usually found in
log/gogs.log
):
2017/03/18 00:43:07 [TRACE] Template: repo/home
2017/03/18 00:43:15 [TRACE] Session ID: 680247266044030b
2017/03/18 00:43:15 [TRACE] CSRF Token: XqrlvbmA3VRS46nV_Uufk3YAt_A6MTQ4OTgxMjE5NTE4NTY5ODg3Mg==
2017/03/18 00:43:15 [TRACE] Session ID: cba1c7a688bd14dc
2017/03/18 00:43:15 [TRACE] CSRF Token: PdAbkOr0oYgJst6rQpmkfuU1rbI6MTQ4OTgxMjE5NTQ4NzI2MTIyNA==
Description
Getting:
Mar 18 00:38:03 quark gogs[17459]: [Macaron] 2017-03-18 00:38:03: Completed POST /david/collantes.me.git/git-receive-pack 401 Unauthorized in 4.46717ms
On git client (Tower.app, macOS).
Full log:
Pushing to https://david@gits.quark.business/david/collantes.me.git
Counting objects: 31, done.
Delta compression using up to 8 threads.
Compressing objects: 3% (1/27)
Compressing objects: 7% (2/27)
Compressing objects: 11% (3/27)
Compressing objects: 14% (4/27)
Compressing objects: 18% (5/27)
Compressing objects: 22% (6/27)
Compressing objects: 25% (7/27)
Compressing objects: 29% (8/27)
Compressing objects: 33% (9/27)
Compressing objects: 37% (10/27)
Compressing objects: 40% (11/27)
Compressing objects: 44% (12/27)
Compressing objects: 48% (13/27)
Compressing objects: 51% (14/27)
Compressing objects: 55% (15/27)
Compressing objects: 59% (16/27)
Compressing objects: 62% (17/27)
Compressing objects: 66% (18/27)
Compressing objects: 70% (19/27)
Compressing objects: 74% (20/27)
Compressing objects: 77% (21/27)
Compressing objects: 81% (22/27)
Compressing objects: 85% (23/27)
Compressing objects: 88% (24/27)
Compressing objects: 92% (25/27)
Compressing objects: 96% (26/27)
Compressing objects: 100% (27/27)
Compressing objects: 100% (27/27), done.
Writing objects: 3% (1/31)
Writing objects: 6% (2/31)
Writing objects: 9% (3/31)
Writing objects: 12% (4/31)
Writing objects: 16% (5/31)
Writing objects: 19% (6/31)
Writing objects: 22% (7/31)
Writing objects: 25% (8/31)
Writing objects: 29% (9/31)
Writing objects: 32% (10/31)
Writing objects: 35% (11/31)
Writing objects: 38% (12/31)
Writing objects: 41% (13/31)
Writing objects: 48% (15/31)
Writing objects: 51% (16/31)
Writing objects: 54% (17/31)
Writing objects: 58% (18/31)
Writing objects: 61% (19/31)
Writing objects: 64% (20/31)
Writing objects: 67% (21/31)
Writing objects: 70% (22/31)
Writing objects: 74% (23/31)
Writing objects: 77% (24/31)
Writing objects: 80% (25/31)
Writing objects: 83% (26/31)
Writing objects: 87% (27/31)
Writing objects: 90% (28/31)
Writing objects: 93% (29/31)
Writing objects: 96% (30/31)
Writing objects: 100% (31/31)
Writing objects: 100% (31/31), 359.70 KiB | 0 bytes/s, done.
Total 31 (delta 3), reused 0 (delta 0)
POST git-receive-pack (368506 bytes)
error: RPC failed; HTTP 502 curl 22 The requested URL returned error: 502 Bad Gateway
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
Everything up-to-date
When trying to push a commit. I can commit one small file, no problems. If I try to add several files, or directories, the error occurs. From server’s /var/log/syslog
:
Mar 18 00:50:04 quark gogs[17459]: [Macaron] 2017-03-18 00:50:04: Started GET /david/collantes.me.git/info/refs?service=git-receive-pack for XXX.XXX.XXX.XXX
Mar 18 00:50:04 quark gogs[17459]: [Macaron] 2017-03-18 00:50:04: Completed GET /david/collantes.me.git/info/refs?service=git-receive-pack 200 OK in 18.748727ms
Mar 18 00:50:04 quark gogs[17459]: [Macaron] 2017-03-18 00:50:04: Started POST /david/collantes.me.git/git-receive-pack for XXX.XXX.XXX.XXX
Mar 18 00:50:04 quark gogs[17459]: [Macaron] 2017-03-18 00:50:04: Completed POST /david/collantes.me.git/git-receive-pack 401 Unauthorized in 3.706604ms
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 48 (39 by maintainers)
Like @netlander the workaround of bypassing the Apache proxy worked for me. It was crashing at that step: “POST git-receive-pack (7200216 bytes)”, but this works normally without the proxy.
Might well be related to the 401: with the Apache mod_proxy, I did not receive an authentication request, but I received one without the proxy and had to type user/password for the commit to be accepted.
Apache error log (multiple identical lines):
Gogs log/hooks/post-receive.log (9:20 is without the proxy, nothing visible at 9:12 with the proxy):
Other log/hooks/* files are touched but empty
Portion of the log/gogs.log which appears relevant, without the proxy:
More interestingly, updating my HTTPS Vhost to look like this, as suggested on https://httpd.apache.org/docs/2.4/en/mod/mod_proxy.html#envsettings , fixed the issue for me. It causes the browser to ask for credentials (triggering keychain access in macOS), and succeeds:
This might suggest a problem with HTTP/1.1 keepalive handling in Gogs or its dependencies.
I had this error with Gitlab behind an Nginx proxy with pushing large files.
This was my solution for nginx based on @fgm and the keepalive clue: (SSL terminated at a higher layer, this is for the internal LB in front of docker containers) Narrowed down the issue to
proxy_http_version
,keepalive
and removing the connection header.Something else that can help to narrow down the cause:
GIT_CURL_VERBOSE=1 GIT_TRACE=1 git push origin master
Ran also into this issue today. We have several repos, and only one cannot be pushed anymore. Using apache2.2, gogs 0.11.34 and reverse proxy.
SetEnv proxy-sendcl 1
didn’t help. Setting the git http.postBuffer to 524288000 didn’t help.The workaround that helped was to bypass the proxy. So I changed gogs to listen on the lan ip and change the remote url to connect to port 3000 directly. Then I could push, revert above changes, and newly pushed commits are working again.
So this seems to be a strange combination of things. The problematic push had 5 commits, maybe it’s a size problem?
@Unknwon installed
Caddy
, no problems. I am assuming it was anApache
, amod_proxy
or amod_proxy_http
problem. Weird it did not presented itself with other applications, butgogs
. Shrugs.Another tidbit. I installed
Gitea
(the bastard fork 😂) and it works fine, so it seems the issue is related toGogs
.