Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Prullenbak's avatar

Forge with custom Gitlab access issues

Hi,

We've run into a problem with Laravel Forge and support doesn't seem able to help me. So maybe somebody over here has seen this problem and can help...

We have a self hosted custom gitlab, and I had connected our forge server to it. It was working fine (after some hoops to go through a couple of months ago, but that was all sorted). Yesterday, an automatic deploy started, but went wrong. So we tried to fix the problem and then hit the "deploy now" button (that was working before) but now, we get the error message:

The repository or branch could not be found. Please review your deployment branch and Git remote settings below.

We tried creating a new "project access token" in Gitlab and adding that to my account, but it doesn't seem to do anything. It does create a new user in our gitlab project, but gitlab still says "last used: never" in the token list for the new access token. (This almost seems to indicate to me that forge is never trying to use the new token??)

We tried hitting the "update git remote" button, but that gives the error

That repository is invalid or you do not have permission to access it. Alternatively, the current branch name may not exist on the given repository or the repository may be empty.

The repository, of course exists, and the branch exists also. Everything was working fine until the failed deployment yesterday.

I hope anyone has seen this problem and knows what to do.

0 likes
1 reply
LaryAI's avatar
Level 58

It sounds like there might be an issue with the SSH key or access token that Laravel Forge is using to communicate with your self-hosted GitLab instance. Here are a few steps you can take to troubleshoot and resolve the issue:

  1. Verify SSH Key: Ensure that the SSH key Forge is using is still present and has the correct permissions in your self-hosted GitLab. You might need to re-add the SSH key to your GitLab user's settings if it was somehow removed.

  2. Check Repository and Branch Names: Double-check that the repository and branch names are correctly set in Forge. They must match exactly with what is in your GitLab, including case sensitivity.

  3. Test SSH Connection: You can manually test the SSH connection from your Forge server to your GitLab server using the following command:

ssh -T [email protected]

Replace your-gitlab-domain.com with your actual GitLab domain. This will help you verify if the SSH connection is working correctly.

  1. Project Access Token: If you're using a project access token, ensure that it has the correct scopes (typically api, read_repository, and write_repository) and that it is correctly configured in Forge. You might need to update the token in Forge's source control settings.

  2. Webhooks: Check if the webhooks from GitLab to Forge are still working. A failed deployment could sometimes be due to webhooks not firing correctly.

  3. Manual Git Commands: Try running manual git commands on the Forge server to see if you can access the repository. For example:

git clone [email protected]:namespace/project.git

Replace your-gitlab-domain.com:namespace/project.git with your actual repository path. If this fails, it will give you more information about what might be wrong.

  1. Forge Support with Detailed Logs: If none of the above steps work, you may need to contact Forge support again but this time provide them with detailed logs of the errors you're encountering. This could help them pinpoint the issue more effectively.

  2. Permissions and Access: Ensure that the user associated with the SSH key or access token in Forge has the necessary permissions to access the repository and perform deployments.

Here's a sample checklist you can follow:

  • SSH key is added to GitLab and has correct permissions.
  • Repository and branch names are correct in Forge.
  • SSH connection from Forge to GitLab works.
  • Project access token has the correct scopes and is updated in Forge.
  • Webhooks are functioning correctly.
  • Manual git commands work on the Forge server.
  • Detailed error logs are provided to Forge support if needed.
  • User permissions are correctly set in GitLab.

By following these steps, you should be able to identify and fix the issue with your custom GitLab access in Laravel Forge.

Please or to participate in this conversation.