The GitLab CI pipeline trigger mechanism is failing because the upstream pipeline cannot establish a secure connection to the downstream project’s API.

Common Causes and Fixes:

  1. Incorrect or Expired Project Access Token: The most frequent culprit is a Personal Access Token (PAT) or Project Access Token used for triggering that has expired, been revoked, or lacks the necessary api scope.

    • Diagnosis: In the upstream project’s CI/CD settings, check the CI/CD > Variables section for the token used in the trigger. Then, navigate to the downstream project’s User Settings > Access Tokens (for PATs) or Project Settings > Access Tokens (for Project Access Tokens). Verify the token’s expiry date and its scopes.
    • Fix: If expired or revoked, create a new token with at least the api scope and the read_repository scope. Update the CI/CD variable in the upstream project with the new token’s value.
    • Why it works: The token is the credential GitLab CI uses to authenticate its request to the downstream project’s API. If it’s invalid, the downstream project rejects the connection attempt.
  2. Missing or Incorrect Trigger Token Variable Name: The CI/CD variable in the upstream project that stores the downstream project’s trigger token might be misnamed or simply missing.

    • Diagnosis: Examine the .gitlab-ci.yml file in the upstream project where the trigger job is defined. Look for the CI_JOB_TOKEN or a custom variable name being used to pass the token to the trigger API call. Then, check the CI/CD > Variables section of the upstream project for a variable with that exact name.
    • Fix: Ensure the CI/CD Variable in the upstream project has the correct key (e.g., DOWNSTREAM_TRIGGER_TOKEN) and that this key is correctly referenced in the .gitlab-ci.yml file using "$DOWNSTREAM_TRIGGER_TOKEN".
    • Why it works: The trigger job needs to fetch the token from its environment variables to include in the API request. If the variable name doesn’t match, the token can’t be retrieved.
  3. Network Connectivity Issues or Firewall Restrictions: The GitLab CI runner executing the upstream pipeline might not be able to reach the GitLab API endpoint for the downstream project due to network restrictions.

    • Diagnosis: From the runner’s environment, attempt to curl the GitLab API endpoint for the downstream project. For example, curl --head "https://gitlab.com/api/v4/projects/<downstream_project_id>" (replace <downstream_project_id> with the actual ID). Check for timeouts or connection refused errors. Also, review any firewall rules or network security groups applied to the runner’s network.
    • Fix: If network issues are found, adjust firewall rules, proxy settings, or network configurations to allow outbound HTTPS (port 443) traffic from the runner to gitlab.com (or your self-hosted GitLab instance’s domain).
    • Why it works: The trigger mechanism is an HTTP request. If the runner cannot physically send that request to the GitLab API server, the trigger will fail.
  4. Incorrect Downstream Project API URL: The trigger configuration might be pointing to the wrong GitLab instance or an incorrect API path.

    • Diagnosis: Verify the CI_API_V4_URL variable or the explicitly defined API endpoint in your trigger configuration. If you’re using a self-hosted GitLab instance, ensure the URL is correct and accessible.
    • Fix: Update the CI_API_V4_URL variable in the upstream project’s CI/CD settings or correct the API endpoint in the .gitlab-ci.yml to match your GitLab instance’s domain (e.g., https://gitlab.yourcompany.com/api/v4).
    • Why it works: The trigger job needs to send its request to the correct API server for the downstream project to receive it.
  5. Downstream Project Not Found or Incorrect Project ID: The trigger configuration might be referencing a downstream project that no longer exists, has been renamed, or the project ID is incorrect.

    • Diagnosis: In the upstream project’s .gitlab-ci.yml, identify the project_id being used in the trigger configuration. Navigate to the downstream project’s settings page and confirm its ID matches.
    • Fix: Update the project_id in the upstream .gitlab-ci.yml to the correct ID of the existing downstream project.
    • Why it works: The API request is targeted at a specific project. If that project doesn’t exist at the specified ID, the API will return an error.
  6. GitLab Instance Downtime or API Issues: In rare cases, the GitLab API itself might be experiencing issues or downtime, preventing any API interactions, including pipeline triggers.

    • Diagnosis: Check the GitLab Status page (https://status.gitlab.com/) for any ongoing incidents. If using a self-hosted instance, check your server’s logs for API-related errors.
    • Fix: Wait for GitLab to resolve the API issues. If on a self-hosted instance, troubleshoot your GitLab application and database.
    • Why it works: The trigger is an API call. If the API server is unavailable or malfunctioning, no calls can succeed.

The next error you’ll likely encounter after fixing these is a "403 Forbidden" if the token has the wrong permissions (e.g., missing api scope but is otherwise valid) rather than being outright invalid.

Want structured learning?

Take the full Gitlab-ci course →