git clone or fetch dies with: unable to update url base from redirection
fatal: unable to update url base from redirection:Short answer
Git asked for one URL, got redirected, and the final URL did not end with the same path piece it requested. Git then cannot learn the new base address and stops on purpose. Run a verbose request to see where you land. Use the real repository URL in your remote, or fix the redirect rule on the server.
Fix it fast
1Find out which cause you have
Trace the redirect chain Git sees, using the same URL as your remote. The last Location line is where Git ended up.
git remote -v GIT_CURL_VERBOSE=1 git ls-remote 2>&1 | grep -i -E "^< (HTTP|location)"2Match what you see, then jump to its fix
What does the error look like?
fatal: unable to update url base from redirection:asked for: https://example.com/team/app.git/info/refs?service=git-upload-packredirect: https://example.com/login
Cause 1 of 2
The server redirects to a page that is not the repository
1Check
Git follows a redirect on the first request only, and uses the final URL as the new base for later requests. To do that it strips the same ending it asked for from the final URL. If the final URL does not end with it, Git gives up. A login page, a captive portal or a proxy rule that sends everything to one page causes exactly that.
curl -sIL "https://example.com/team/app.git/info/refs?service=git-upload-pack" | grep -i -E "^(HTTP|location)"2Fix
Fix the rule on the server or proxy so the git paths are passed through, or authenticate first so the request is not sent to the login page. Do not work around it by turning redirects off, which makes every redirect an error.
# check what git is configured to do (default is initial)
git config --get http.followRedirects3Verify
The same curl call now returns 200 or 401 on the git path, not a redirect to a page.
git ls-remote originConfirmed by raw.githubusercontent.com
Cause 2 of 2
The repository moved and the remote still has the old URL
1Check
Compare your remote with the address the server reports. A renamed or transferred repository, or a changed host name, redirects the old path.
git remote get-url origin2Fix
Point the remote at the new address. Git follows a redirect on the initial request only, so the stored URL should be the final one.
git remote set-url origin https://example.com/new-group/app.git3Verify
Fetch from the remote with no redirect error.
git fetch originConfirmed by git-scm.com
How do I stop it coming back?
- Update remotes after a repository is renamed or moved, instead of relying on the old URL.
- When you put a proxy in front of a Git server, pass the Git paths through unchanged.
- Test a new proxy or login rule with git ls-remote before telling the team.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Related fixes
Servers
dnf cannot install MySQL on Amazon Linux 2023
dnf cannot find a mysql-server package on Amazon Linux 2023
Amazon Linux 2023 documents MariaDB, not MySQL, as its database server, with packages named mariadb105 and mariadb105-server.
3 causes, each with a fixServers
Ansible hangs, then times out waiting for the sudo prompt
a playbook using become seems to hang
Ansible ran sudo on the target and never saw the answer it expected.
3 causes, each with a fixServers
Apache on Ubuntu returns 404 Not Found for my site
The requested URL was not found on this server.
On Ubuntu a 404 from Apache usually means the request maps to a path that has no file.
3 causes, each with a fixServers
Apache returns 504 Gateway Timeout when PHP takes too long
Quick requests work, slow ones end in a 504 after a fixed wait
A 504 from Apache means the backend did not answer within the proxy timeout.
2 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fixServers
Apache warns that a ${VAR} config variable is not defined
${VAR} left unchanged in the configuration, with a warning in the error log
Apache expands ${VAR} from Define or from the shell environment that exists when the server starts.
3 causes, each with a fix