How to fix error: RPC failed; curl 56 GnuTLS recv error (-9): A TLS packet with unexpected length was received. in Git

GitINTERMEDIATEMEDIUMUpdated Dec 6, 2025ยท 684 views

The 'RPC failed; curl 56 GnuTLS' error occurs during Git operations over HTTPS when there's a TLS/SSL communication failure. This is commonly caused by network issues, large repository transfers, or GnuTLS library problems on Linux systems.

Quick fix

Fixes error: RPC failed; curl 56 GnuTLS recv error (-9): A TLS packet with unexpected length was received.

# Increase buffer to 500 MB
git config --global http.postBuffer 524288000

# For very large repositories, try 1 GB
git config --global http.postBuffer 1048576000
  1. Increase Git HTTP buffer size
  2. Use shallow clone for large repositories
  3. Enable verbose output for debugging
  4. Use SSH instead of HTTPS
git โ€” error
# Increase buffer to 500 MB
git config --global http.postBuffer 524288000
# For very large repositories, try 1 GB
git config --global http.postBuffer 1048576000
error: RPC failed; curl 56 GnuTLS recv error (-9): A TLS packet with unexpected length was received.

What this error means

The "RPC failed; curl 56 GnuTLS recv error" message indicates that Git's HTTP transfer failed due to a TLS (Transport Layer Security) communication problem. The error code 56 refers to curl's CURLE_RECV_ERROR, meaning data could not be received from the remote server. Git uses the curl library for HTTPS operations, and on many Linux distributions (particularly Ubuntu and Debian), curl is compiled with GnuTLS rather than OpenSSL for SSL/TLS support. GnuTLS can sometimes be more sensitive to network issues or have compatibility problems with certain server configurations. The specific GnuTLS error code (like -9 for unexpected packet length, -110 for improper termination, or -54 for pull function errors) provides additional context. These errors typically occur during clone, push, pull, or fetch operations, especially with large repositories or over unstable network connections.

Typical symptoms

  • git clone fails with 'RPC failed; curl 56 GnuTLS recv error' message
  • git push or git pull hangs then fails with TLS error
  • Error occurs intermittently and cannot be reproduced consistently
  • Large repository operations fail while small operations succeed
  • Error appears more frequently on slow or unstable network connections
  • Other HTTPS operations work fine, but Git operations fail
  • Error message includes various GnuTLS error codes like -9, -54, or -110

Common causes

  1. Network instability or connection timeouts during large transfers
  2. Git's HTTP post buffer is too small for the repository size
  3. GnuTLS library incompatibilities with server TLS configuration
  4. Proxy, firewall, or TLS inspection device interfering with connection
  5. Server-side HTTP/2 configuration issues
  6. Outdated Git or GnuTLS version with known bugs
  7. Antivirus or security software intercepting TLS connections
  8. Corporate network with TLS MITM (man-in-the-middle) proxy

How to fix "error: RPC failed; curl 56 GnuTLS recv error (-9): A TLS packet with unexpected length was received."

1Increase Git HTTP buffer size

The most common fix is to increase Git's HTTP buffer size. By default, Git uses a relatively small buffer which can cause issues with large repositories:

bash
# Increase buffer to 500 MB
git config --global http.postBuffer 524288000

# For very large repositories, try 1 GB
git config --global http.postBuffer 1048576000

After setting this, retry your Git operation. Note that this increases memory usage during Git HTTP operations.

2Use shallow clone for large repositories

If you're cloning a large repository, try a shallow clone to reduce the amount of data transferred:

bash
# Clone with limited history
git clone --depth 1 https://github.com/user/repo.git

# If you need more history later, unshallow
cd repo
git fetch --unshallow

This downloads only the latest commit initially, which is much less data and reduces the chance of TLS errors.

3Enable verbose output for debugging

Enable Git's debugging output to get more information about where the failure occurs:

bash
# Set environment variables for verbose output
export GIT_TRACE_PACKET=1
export GIT_TRACE=1
export GIT_CURL_VERBOSE=1

# Now run your git command
git clone https://github.com/user/repo.git

This will show detailed information about the HTTP/TLS communication and help identify the exact point of failure.

4Use SSH instead of HTTPS

Switching from HTTPS to SSH bypasses GnuTLS entirely and often resolves the issue:

bash
# Clone using SSH instead of HTTPS
git clone git@github.com:user/repo.git

# For existing repositories, change the remote URL
git remote set-url origin git@github.com:user/repo.git

You'll need to set up SSH keys if you haven't already:

bash
# Generate SSH key (if you don't have one)
ssh-keygen -t ed25519 -C "your_email@example.com"

# Add key to ssh-agent
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

# Copy public key to add to GitHub/GitLab
cat ~/.ssh/id_ed25519.pub
5Update Git to the latest version

Older Git versions may have known GnuTLS-related bugs. Update to the latest version:

bash
# Ubuntu/Debian - add Git PPA for latest version
sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git

# Fedora/RHEL
sudo dnf upgrade git

# macOS
brew upgrade git

# Check version
git --version
6Configure Git to use OpenSSL instead of GnuTLS

If the issue persists, you can configure Git to use OpenSSL as the SSL backend (if available):

bash
# Check available SSL backends
git config --global --list | grep ssl

# Set OpenSSL as the backend (if installed)
git config --global http.sslBackend openssl

If your system doesn't have OpenSSL support in Git, you may need to reinstall Git with OpenSSL. On Ubuntu:

bash
# Install build dependencies
sudo apt-get install build-essential libcurl4-openssl-dev libexpat1-dev gettext libz-dev libssl-dev

# Download and compile Git with OpenSSL (advanced)
wget https://github.com/git/git/archive/v2.43.0.tar.gz
tar -xzf v2.43.0.tar.gz
cd git-2.43.0
make prefix=/usr/local NO_GNUTLS=1 all
sudo make prefix=/usr/local install
7Check for network issues and proxies

Network configuration issues can cause TLS failures. Check your network setup:

bash
# Check if proxy is configured
git config --global --get http.proxy
git config --global --get https.proxy

# Temporarily unset proxy to test
git config --global --unset http.proxy
git config --global --unset https.proxy

# If behind corporate proxy, ensure it's configured correctly
git config --global http.proxy http://proxy.company.com:8080

If you're on a corporate network with TLS inspection, you may need to add the corporate CA certificate:

bash
# Add corporate CA certificate
git config --global http.sslCAInfo /path/to/corporate-ca.crt
8Disable SSL verification (temporary workaround)

As a last resort for testing, you can temporarily disable SSL verification. Warning: This is insecure and should not be used for production!

bash
# Disable SSL verification temporarily (NOT RECOMMENDED for production)
git config --global http.sslVerify false

# Run your git command
git clone https://github.com/user/repo.git

# Re-enable SSL verification immediately after
git config --global http.sslVerify true

Only use this to confirm the issue is TLS-related. Never leave SSL verification disabled as it exposes you to man-in-the-middle attacks.

Advanced notes

### Understanding GnuTLS Error Codes

Different GnuTLS error codes indicate different problems:
- -9 (unexpected length): Received a TLS packet with unexpected size, often due to connection issues
- -54 (pull function error): Error in the underlying socket read operation
- -110 (improper termination): TLS connection closed abnormally
- -12 (fatal alert): Server sent a TLS fatal alert

### HTTP/2 Server Configuration

If you control the Git server (e.g., self-hosted GitLab), ensure HTTP/2 is properly configured. Some users have reported that disabling HTTP/2 on the server reproduces the error, while enabling it resolves it. In nginx:

nginx
server {
    listen 443 ssl http2;
    # ... rest of config
}

### WSL and Windows-Specific Issues

On Windows Subsystem for Linux (WSL), this error can occur due to:
- Network driver issues between WSL and Windows
- Windows Defender or antivirus scanning network traffic

Try these WSL-specific fixes:

bash
# In WSL, use Windows Git for network operations
git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/bin/git-credential-manager.exe"

### Git Compression Settings

Adjusting compression can sometimes help with transfer issues:

bash
# Disable compression
git config --global core.compression 0

# Or set compression level (0-9, -1 for default)
git config --global core.compression -1

### Alternative: Git Protocol Version

Try forcing a specific Git protocol version:

bash
# Use Git protocol version 2
git config --global protocol.version 2

# Or fall back to version 1
git config --global protocol.version 1

Frequently asked questions

What does "error: RPC failed; curl 56 GnuTLS recv error (-9): A TLS packet with u" mean?
The "RPC failed; curl 56 GnuTLS recv error" message indicates that Git's HTTP transfer failed due to a TLS (Transport Layer Security) communication problem. The error code 56 refers to curl's CURLE_RECV_ERROR, meaning data could not be received from the remote server. Git uses the curl library for HTTPS operations, and on many Linux distributions (particularly Ubuntu and Debian), curl is compiled with GnuTLS rather than OpenSSL for SSL/TLS support.
How do I fix "error: RPC failed; curl 56 GnuTLS recv error (-9): A TLS packet with u"?
The 'RPC failed; curl 56 GnuTLS' error occurs during Git operations over HTTPS when there's a TLS/SSL communication failure. This is commonly caused by network issues, large repository transfers, or GnuTLS library problems on Linux systems.
What causes "error: RPC failed; curl 56 GnuTLS recv error (-9): A TLS packet with u"?
Network instability or connection timeouts during large transfers Git's HTTP post buffer is too small for the repository size GnuTLS library incompatibilities with server TLS configuration
Is the "error: RPC failed; curl 56 GnuTLS recv error (-9): A TLS packet with u" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading