Skip to main content

Error when Push Source Code

The error message

> git push origin main:main
error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413
send-pack: unexpected disconnect while reading sideband packet
fatal: the remote end hung up unexpectedly
Everything up-to-date

The error you're seeing is related to a Git push issue, where the data being pushed exceeds the allowed size for HTTP requests. Specifically, the HTTP 413 error indicates that the request is too large, and it can happen when pushing large commits or files.

Solution Steps

1. Increase Git HTTP Buffer Size

The most common fix is to increase the buffer size for Git's HTTP operations. You can do this by configuring Git with a larger buffer size on your local machine.

Run this command to increase the Git HTTP buffer size:

git config --global http.postBuffer 524288000  # 500MB

2. Configure Gitea to Allow Larger Pushes (Optional)

If increasing the buffer on your client doesn't work, you may need to adjust the settings in Gitea to allow larger pushes.

1. Edit the Gitea configuration (app.ini):

  • If you're using the default Gitea deployment, this file is located in the Gitea container or in the /data/gitea/conf/ directory (depending on your setup).
  • Look for the [server] section and set the following options:
[server]
; Max size for HTTP upload, in MB
MAX_UPLOAD_SIZE = 1024

2. Restart Gitea to apply the configuration changes:

kubectl rollout restart deployment gitea -n git

3. Increase Kubernetes Resource Limits (Optional)

If your Gitea pod has limited CPU or memory, it might be throttling large requests. You can increase the resource limits for the Gitea pod in your Kubernetes deployment configuration.

For example, add resource limits in the deployment YAML:

resources:
  requests:
    memory: "512Mi"
    cpu: "500m"
  limits:
    memory: "2Gi"
    cpu: "1"

Apply the changes with:

kubectl apply -f gitea-deployment.yaml

4. Push in Smaller Batches

If the file you're pushing is very large, you can try pushing smaller commits or files in batches to avoid hitting the request size limit.

After Applying Changes

  • Run the git push origin main:main command again.
  • If the problem persists, check if you are pushing very large files. You can use Git LFS (Large File Storage) for handling large binary files in your repository.