Running Kong for local development

Hello,

I’m pretty much new to KONG and I’ve tried several ways to make it work on my local machine, on an exposed web server it works with no problems.

The problem I’m having is since the local apis are only available on the HOST Localhost, and KONG runs in a docker container.

What I’ve tried doing:

curl -i -X POST \
  --url http://localhost:8001/apis/ \
  --data 'name=MY_API' \
  --data 'upstream_url=MY_API_VHOST' \
  --data 'uris=/MY_API' \
  --data 'hosts=MY_HOST_IP \
  -d 'methods=GET,HEAD,POST,DELETE'

Also mix and maching the upsream_url and hosts, also making sure I have port forwarding so CONTAINER -> HOST can communicate.

Can someone help me, I feel like I"m missing something, shouldn’t this have a upstream_ip and upstream_host ?

Hi,

host.docker.internal should resolve to the host machine from inside the docker instance. Try using that instead of localhost. Reference: https://docs.docker.com/docker-for-mac/networking/#use-cases-and-workarounds

Hi, first of all thanks for the quick reply, I wasn’t expecting it to be this fast.

I have tried, now i have

curl -i -X POST \
  --url http://localhost:8001/apis/ \
  --data 'name=MY_API' \
  --data 'upstream_url=MY_API_VHOST' \
  --data 'uris=/MY_API' \
  --data 'hosts=host.docker.internal \
  -d 'methods=GET,HEAD,POST,DELETE'

The problem I have now is that the uri is not found. I’ve checked and I can find it in the /apis/ .

{“message”:“no route and no API found with those values”}

Hi, that error is typically shown when traffic is being sent to the proxy port but it can not match any existing routes.

Could you please describe your service, route that should be matched and the request that generated this error? (anonymized is ok).

1 Like