Default docker-compose influxDB+Grafana has issue hitting localhost API

Hi, I have been trying k6 lately and it’s awesome!

Ran into an issue yesterday. I followed the instructions here (Grafana dashboards) to get the default dockerized k6+influxDB+Grafana running. It works perfectly fine when sending requests to any public APIs I tried. However when I tried to hit the API hosted on my local machine with the same dockerized setup, I got the following error:
WARN[0000] Request Failed error=“Get "https ://localhost:7110/weatherforecast": dial tcp 127.0.0.1:7110: connect: connect
ion refused”

I can hit this endpoint fine running ‘k6 run’ directly and can also curl works as well.

I created the localhost API by simply following the MS ‘created a web API with ASP. NET Core’ tutorial and used the template.

It seems to me docker compose got blocked by port 7110. Do I need to change docker-compose.yaml to open up this port? I tried to look up docker documentations but couldn’t figure it out myself.

Sorry I am new to both k6 and docker.

1 Like

Hi @yli,
welcome to the community forum :tada:

I expect you are misconfiguring the networking between containers. You can read more about Docker and Docker Compose networking on this documentation page and how to link containers.

Hi Ivan, thanks for getting back to me. I didn’t configure container network at all though. I used the default k6 config. The localhost API I am trying to hit is not in any container and was created in .net with 1 command line ‘dotnet new webapi -o weatherforecast’. k6, influxdb and grafana seem to communicate with each other totally fine inside docker containers since when I tried any real API on the internet, it works perfectly fine.