LoginSignup
0
1

More than 1 year has passed since last update.

【GitLab CI】Gitへの接続失敗でジョブが失敗するときの対処法

Posted at

前提

私が確認した環境は次の通りです。

GitLabサーバ: WSL2上のdockerでローカルに構築
GitLab RunnerをインストールしたホストOS: Windows 10, Windows 11
利用したExecutor: docker

ジョブが失敗した時のメッセージ

失敗した時のジョブの詳細は[CI/CD] > [ジョブ]から確認することができます。
次のようなエラーメッセージが出ていました。

fatal: unable to access 'http://localhost/*********/test.git/': Failed to connect to localhost port 80 after 0 ms: Connection refused
ERROR: Job failed: exit code 1

対処法

Runnerの設定ファイル「config.toml」の[[runners]]の設定のurl及びclone_urlの値をlocalhostからプライベートIPアドレスに変更する。(プライベートIPアドレスはご自分の環境に合わせて設定してください。)

config.toml
concurrent = 1
check_interval = 0

[session_server]
  session_timeout = 1800

[[runners]]
  name = "docker"
  url = "http://192.168.*.*/"
  clone_url = "http://192.168.*.*/"

私はWSL2のローカル上でGitLabサーバーを立てているので、元々は、http://localhost/で登録していました。
しかし、Executorのdockerコンテナ内からだと、GitLabサーバーに対して、localhostのURLではアクセスできないようで、ホストOSのプライベートIPアドレスを明示的に指定する必要がありました。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1