Why can't gitlab-runner clone my project? (Exec. shell, Incorrect hostname, failed to connect)

Hello,
I am stuck with a problem and hope you can help me.

I set-up a Gitlab server and need to run tests Windows using gitlab-runner.exe.

When the test is spawned on a commit it fails with

Cloning into ‘C:/git/builds/ac70aeb9/0/test/myproject’…
fatal: unable to access ‘http://gitlab-ci-token:xxxxxxxxxxxxxxxxxxxx@localhost/test/boundaries.git/’: Failed to connect to localhost port 80: Connection refused

The gitlab-runner’s executor is set to shell, the config.toml looks like

concurrent = 1
check_interval = 0

[[runners]]
  name = "PC123"
  url = "http://1.2.3.4/ci"
  token = "cd2b093adc5ca09ea41ee4eadb0752"
  executor = "shell"
  [runners.cache]

I suppose the problem is the hostname “localhost” in the URL, which should refers to the server, but points to the machine gitlab-runner is on. When I set-up the server in the beginning I used ‘localhost’ as the servers hostname. This was probably not the best idea. :slight_smile:

In the meantime I changed the servers hostname to “localgit”, but the URL does not adjust, it still shows “localhost”. (Server restarted, gitlab-runner servive restart). At best this should not use the hostname at all, but the IP.

Could it be that the server’s hostname is stored somewhere in the original repo that I cloned when the hostname was still localhost? The projects .git/config shows the correct IP:

[remote "origin"]
    url = http://1.2.3.4/test/myproject.git

I found another questions that mentions a way to add other hosts to gitlab-runner’s config.toml, like

[runners.docker]
    extra_hosts = ["ci.mygitlab:127.0.0.1"]

But I must use the shell executor, not docker.

Found a solution

As described here, the solution is to replace the entry host: localhost in the Github config file /home/git/gitlab/config/gitlab.yml with the IP address of the host.

My answer is also here: