Jenkins: Failed to connect to repository
Jenkins: Failed to connect to repository
DodaTech
2 min read
The Jenkins error “Failed to connect to repository” occurs during the SCM checkout stage when Jenkins cannot reach or authenticate with the Git repository. The build fails before any code is fetched.
What It Means
Jenkins attempted to clone or fetch from a Git repository URL configured in the job, but the connection failed. This can happen at the network level (host unreachable), the authentication level (bad credentials), or the protocol level (wrong URL format).
Why It Happens
- The repository URL is incorrect or missing.
- SSH keys are not configured in Jenkins credentials for SSH-based repos.
- Username/password or personal access token is missing or expired for HTTPS repos.
- The Jenkins agent does not have network access to the Git server.
- The Git server’s host key has changed or is not trusted.
- The Jenkins credential ID referenced in the job is wrong or deleted.
How to Fix It
1. Verify the repository URL
git ls-remote https://github.com/user/repo.git2. Test SSH authentication
ssh -T git@github.comExpected message: Hi user! You've successfully authenticated...
3. Add credentials in Jenkins
Manage Jenkins → Manage Credentials → Add credential:
- For HTTPS: Username with password or Personal Access Token
- For SSH: Private key with passphrase
4. Update the job configuration
In the pipeline or freestyle job, set the correct credential ID under “Git” → “Credentials”.
5. Check Git tool installation
git --versionFAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro