Recently, I ran into a recurring and frustrating HTTP 400 RPC failed error when trying to git push my changes to GitHub, particularly from my JetBrains IDE (like IntelliJ IDEA or WebStorm). What made it especially confusing was that it had been working perfectly until last week!
If you’re seeing errors like:
error: RPC failed; HTTP 400 curl 22 The requested URL returned error: 400
send-pack: unexpected disconnect while reading sideband packet
fatal: the remote end hung up unexpectedly
…and you’ve already tried generating new Personal Access Tokens or re-authenticating in your IDE, this guide is for you.
The Problem: Network Interference with HTTPS
My deep dive revealed that the HTTP 400 Bad Request error, especially when it pops up unexpectedly, often points to network-level interference. While HTTPS is generally secure, proxies, firewalls, VPNs, or even changes from an ISP can sometimes inspect or corrupt the Git data packets, making GitHub’s servers reject the request as “malformed.”
The good news is there’s a more resilient way to connect.
The Solution: Switching to SSH for GitHub
The SSH (Secure Shell) protocol provides a more direct and encrypted channel for Git operations, making it far less susceptible to the kind of network interference that causes HTTP 400 errors with HTTPS.
Here’s the step-by-step process I followed to switch my local repositories to SSH, ensuring smooth sailing for pushes and pulls from now on. You’ll need to do these steps for each computer you use to interact with GitHub.
Step 1: Generate a Unique SSH Key Pair for Your Machine
Each computer needs its own unique key pair. Do not copy keys between machines!
- Open your Terminal (macOS/Linux) or Git Bash (Windows).
-
Generate the key: Run the following command. Replace
"your_email@example.com"with the email associated with your GitHub account.ssh-keygen -t ed25519 -C "your_email@example.com"- Prompt for file to save the key: Just press
Enterto accept the default location (~/.ssh/id_ed25519). - Prompt for passphrase: You can press
Entertwice to leave it blank (recommended for simplicity with Git), or set a strong passphrase for extra security (you’ll be prompted for it every time you use the key).
You should see output like:
Your public key has been saved in /Users/YOUR_USERNAME/.ssh/id_ed25519.pubThis creates two files:
id_ed25519(your private key) andid_ed25519.pub(your public key). - Prompt for file to save the key: Just press
Step 2: Add Your New Public SSH Key to Your GitHub Account
Now, we need to tell GitHub about your computer’s public key so it recognizes you.
- Copy your public key to your clipboard:
- On macOS:
pbcopy < ~/.ssh/id_ed25519.pub - On Windows (using Git Bash or WSL):
cat ~/.ssh/id_ed25519.pub | clip(If
clipdoesn’t work, open~/.ssh/id_ed25519.pubwith a text editor and copy the entire content.)
- On macOS:
- Go to GitHub’s SSH settings:
- Open your web browser and navigate to github.com/settings/keys.
- You’ll likely need to re-enter your GitHub password.
- Add the new key:
- Click the
New SSH keybutton. - Title: Give your key a descriptive name (e.g., “My iMac’s Key”, “MacBook Air SSH”, “Work Desktop”). This helps you identify which machine is which.
- Key: Paste the public key you copied from your clipboard into the large text area.
- Click
Add SSH key.
You should now see your new key listed.
- Click the
Step 3: Update Your Local Git Repository to Use the SSH URL
Finally, you need to tell your local Git project to use the SSH address instead of the HTTPS one.
-
Open your Terminal/Git Bash and navigate to your local Git repository’s root directory (e.g.,
cd YOUR_USERNAME.github.io). - Verify your current remote URL (optional):
git remote -vYou’ll likely see something like
https://github.com/YOUR_USERNAME/YOUR_USERNAME.github.io.git. -
Set the new SSH remote URL: Run this command, ensuring
YOUR_USERNAMEis your GitHub username andYOUR_USERNAME.github.iois your repository name:git remote set-url origin git@github.com:YOUR_USERNAME/YOUR_REPOSITORY.git - Verify the new remote URL (optional):
git remote -vYou should now see something like
git@github.com:YOUR_USERNAME/YOUR_USERNAME.github.io.git.
Step 4: Perform Your First SSH Push (and accept the host fingerprint)
Now, try your git push again, either from your IDE or the terminal.
git push