Git Proxy Issues: Unable to Push to GitHub

Git Proxy Issues: Unable to Push to GitHub



When working with Git and GitHub, you might encounter an error like this when pushing your commits:

fatal: unable to access 'https://github.com/username/repo.git/': 
Unsupported proxy syntax in 'proxyaddress:port': Port number was not a decimal number between 0 and 65535

This happens because Git is trying to use a configured proxy, but the proxy settings are either invalid or incomplete.

1. Understanding the Problem

The error is related to Git's proxy configuration. If Git is set to use a proxy that has:

  • A placeholder instead of a real address, e.g., proxyaddress:port
  • An invalid port number (not between 0–65535)

…it will fail to connect to GitHub over HTTPS. Even if your internet works fine, Git cannot route through an invalid proxy.

2. How to Check Git Proxy Settings

To see what proxy Git is using:

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

If these commands return a placeholder or invalid value, that’s causing the push error.

3. How to Fix It

Option A: Remove Proxy (Recommended if you don’t need one)

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

Verify removal:

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

Both should return nothing.

Option B: Correct Proxy Settings (If you need a proxy)

Set the proxy in correct syntax:

git config --global http.proxy http://username:password@proxy.example.com:8080
git config --global https.proxy http://username:password@proxy.example.com:8080

Make sure the port number is between 0–65535 and the address is reachable.

4. Retry Push

git push -u origin main

After removing or fixing the proxy, Git should connect successfully and push your commits.

5. Best Practices

  • Only use a proxy if required by your network.
  • Double-check the port number and address format.
  • If unsure, remove proxy settings to connect directly.
  • Always test connection using git ls-remote or curl https://github.com.

By understanding and managing Git proxy settings, you can avoid connectivity issues and ensure smooth collaboration with GitHub repositories.

Comments