Can't get response from local rest api server

Hello, I’m noob in kong.

I have some question for Kong Service.

I’ve installed kong in docker and add two api Services,Routes

  1. host url : https://jsonplaceholder.typicode.com/ , kong service path : /fakejson
    route method : get

as you know, ‘jsonplaceholder.typicode.com/’ serve fake json data.
when I call localhost:8000/fakejson/users, it works.

  1. host url : ( host.docker.internal or docker.for.mac.host.internal or my global IP / I’ve tried all)
    . kong service path : /local
    route method : get

I’ve run the rest api server(node.js) in local env and I can get right response by direct call
when I use Kong api call, It doesn’t work.

I attached the node server code.
////////////////////////////////////////////////////
var express = require(‘express’);
var app = express();

app.get(’/test1’, function (req, res) {
var samplejson = [{‘hello’ : ‘world’}];
res.send(samplejson);
});

app.get(’/test1/1’, function (req, res) {
var samplejson = {‘hello1’ : ‘world1’};
res.send(samplejson);
});

// Port setting
var port = 34421;
app.listen(port, function(){
console.log(‘server on! http://localhost:’+port);
});
/////////////////////////////////////////////////////////////

Could someone answer me??

I think the problem is about the Docker network.
Kong in docker doesn’t know your NodeJS Express app.
Uses kong in docker with a host network.

The host network work with linux host for service url with loopback.

  • docker-compose
    network_mode: host

  • docker cli
    --net=host

Then you can config kong service with url=http://127.0.0.1:34421

If you use macOS with local NodeJS App dev checking port binding is port binding with 0.0.0.0 for all incoming request.

Hello nanate!

First of all, thank you for answering me,

but I’ve tried ‘curl’ from docker container(KONG) to my local Node Server <- It works

So I guess It is not a problem with container network or port. T_T