Visual Studio push over HTTPS fails: Git failed with a fatal error
Error encountered while pushing to the remote repository: Git failed with a fatal error.Short answer
Visual Studio hides the real message. Run the same git push in a terminal to read it. When it is a certificate error, your Git does not trust the CA that signed the server, often a company or self-hosted GitLab CA. Point http.sslCAInfo at that CA file, and pick the SSL backend that matches where it is trusted.
Fix it fast
1Find out which cause you have
Push from a terminal in the same repository. The message there names the real problem, and tells you which cause below applies.
git push origin main2Match what you see, then jump to its fix
- 1
The terminal reports a certificate verification failure for a self-hosted or company server.Git does not know the certificate authority that signed the serverFix - 2
Browsers open the server without warnings, but Git rejects it.Git uses the OpenSSL backend while the CA is installed in the Windows storeFix - 3
http.sslCAInfo is set, the backend is schannel, and the same error remains.The backend is schannel, so the CA file you set is ignoredFix
- 1
What does the error look like?
Error encountered while pushing to the remote repository: Git failed with a fatal error.Git failed with a fatal error (the Visual Studio message hides the real cause)
Cause 1 of 3
Git does not know the certificate authority that signed the server
1Check
http.sslCAInfo names the file with the certificates Git uses to verify the server when fetching or pushing over HTTPS. See whether it is set, and where.
git config --show-origin --get-all http.sslCAInfo2Fix
Get the CA certificate (PEM) from your administrator and tell Git to use it for that server only.
git config --global http."https://gitlab.example.com/".sslCAInfo "C:/certs/company-ca.pem"3Verify
Push again from the terminal and then from Visual Studio.
git push origin mainConfirmed by git-scm.com
Cause 2 of 3
Git uses the OpenSSL backend while the CA is installed in the Windows store
1Check
http.sslBackend selects the SSL library, openssl or schannel. Secure Channel uses the Windows certificate store, where your company CA is usually installed.
git config --show-origin --get http.sslBackend2Fix
Switch Git to the Secure Channel backend.
git config --global http.sslBackend schannel3Verify
Push again.
git push origin mainConfirmed by git-scm.com
Cause 3 of 3
The backend is schannel, so the CA file you set is ignored
1Check
With schannel, Git tells curl not to use the http.sslCAInfo bundle by default, because it would override the Windows store.
git config --show-origin --get http.schannelUseSSLCAInfo2Fix
Either import the CA into the Windows Trusted Root store and keep schannel, or switch to the openssl backend, or set http.schannelUseSSLCAInfo to true.
git config --global http.schannelUseSSLCAInfo true3Verify
Push again from a terminal.
git push origin mainConfirmed by git-scm.com
How do I stop it coming back?
- Scope the CA file to one server with http.<url>.sslCAInfo, so the setting does not affect other hosts.
- Do not turn off verification (http.sslVerify, or GIT_SSL_NO_VERIFY) to make a push pass; it stops Git from checking the server certificate.
- Keep the CA file in a fixed path that is documented for 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.
Related fixes
Servers
Status code 460 on an AWS Application Load Balancer
elb_status_code 460 in ALB access logs
A 460 is generated by the load balancer, not by your app.
3 causes, each with a fixServers
Application Load Balancer returns 504 for requests to EC2 instances
HTTPCode_ELB_504_Count
A 504 from an Application Load Balancer means it could not get an answer from a target in time.
4 causes, each with a fixServers
apk cannot find py-pip in an Alpine Docker image
py-pip (no such package):
On current Alpine releases there is no package called py-pip.
2 causes, each with a fixServers
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
ng serve runs in the container but localhost:4200 does not open
The browser cannot open localhost:4200 although ng serve is running in the container
ng serve listens on localhost by default, which inside a container is the container itself.
3 causes, each with a fixServers
Angular routes return 404 from nginx when you refresh or open a link
The home page loads, but refreshing /some/route shows an nginx 404
Angular routes like /users/42 are not files, so nginx looks for them on disk and returns 404.
3 causes, each with a fix