Kong gateway (Docker installation) - Connection refused when accessing server

I have installed Kong Gateway using docker installation. I have a FastAPI service running on port 8080 of the host (127.0.0.1:8080).
@app.get(“/test”)
def read_root():
return {“Hello”: “World”)

Here is also how my services on Kong looks like :8001/services - 192.168.42.93 this IP is my host’s IP (because kong is running on the container and as far as I know I should not use loopback ip.
{
“data”: [
{
“host”: “192.168.42.93”,
“enabled”: true,
“retries”: 5,
“write_timeout”: 60000,
“protocol”: “http”,
“port”: 8080,
“tls_verify”: null,
“client_certificate”: null,
“tags”: [
“OAS3_import”,
“OAS3file_openapi.yaml”
],
“tls_verify_depth”: null,
“path”: “/”,
“id”: “7e501eed-c5ba-4d84-9cf5-a4f5234b379f”,
“updated_at”: 1675935518,
“read_timeout”: 60000,
“connect_timeout”: 60000,
“created_at”: 1675935518,
“name”: “XAI_Microservices”,
“ca_certificates”: null
}
],
“next”: null
}

I then managed to get the OpenAPI specs and generated the .yaml file for use by deck Sync.
However, as you can see I cannot access the service by Kong gateway, getting the “Connection refused error”.

kong_1 | 2023/02/09 10:26:49 [error] 1117#0: *7418308 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.170.1, server: kong, request: “GET /test HTTP/1.1”, upstream: “http://192.168.42.93:8080/test”, host: “127.0.0.1:8000”
kong_1 | 192.168.170.1 - - [09/Feb/2023:10:26:49 +0000] “GET /test HTTP/1.1” 502 75 “-” “insomnia/2022.7.5”

any help would be appreciated pls!

If you use macos, try using host.docker.internal as the service host.

If you use linux, find your docker network (which kong container is running) gateway ip and use that as service host.