Service/Route for upstream service other than port 80/443


I am trying to configure Service and Route for my local service using Kong community with 0.13.1 version.

Below is the information

Upstream URL : localhost:5077/v1/vehicle/makes

To configure service I have used following commands

//------ Create Service------//
curl -i -X POST --url http://localhost:8001/services --data “name=VehicleDataQueryService” --data “protocol=https” --data “host=localhost” --data “port=5077”

//-------Create Route------//
curl -i -X POST --url http://localhost:8001/services/VehicleDataQueryService/routes --data “hosts[]=localhost” --data “paths[]=/v1/vehicle/makes”

//------- Consume API -----//
curl -i -X GET --url http://localhost:8000/v1/vehicle/makes --header “Host:localhost”

This gives me an error saying unexpected error occurred,

I am sure I miss something so that can map a route to localhost:5077 port.

Appreciate your help.


Hi Keyur,

Please try using your local IP address ( instead of localhost.

If that doesn’t work, please provide the exact error that you receive and the nginx error log.


Hi @kikito,

Thanks a lot for your response.
I have tried the way you suggested to use the instead of local host.

New set of command

curl -i -X POST --url --data “name=VehicleDataQueryService” --data “protocol=http” --data “host=” --data “port=5077”

curl -i -X POST --url --data “hosts[]=” --data “paths[]=/v1/vehicle/makes”

curl -i -X GET --url --header “Host:”
I am running Kong on windows using docker for windows.

Here is the container log
2018/05/21 05:25:38 [error] 18#0: *4965 connect() failed (111: Connection refused) while connecting to upstream, client:, server: kong, request: “GET /v1/vehicle/makes HTTP/1.1”, upstream: “”, host: “” - - [21/May/2018:05:25:38 +0000] “GET /v1/vehicle/makes HTTP/1.1” 502 160 “-” “Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36”

Though, I am new to Kong not sure how to find the NGINX error log.
I suspect its connection refused.

When I use curl command

C:\curl\I386>curl -i -X GET --url --header “Host:”
HTTP/1.1 502 Bad Gateway
Date: Mon, 21 May 2018 05:29:34 GMT
Content-Type: text/plain; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Server: kong/0.13.1

An invalid response was received from the upstream server

Hope this helps to investigate the issue.

Your backend :


Is connection refusing your proxy request. Is the back-end service up? Interesting case having nginx proxy to itself but its certainly doable because the Admin api loop-back technique within Kong is the same sort of impl.

Try curling directly, if that is failing then gotta work on getting your backend service functional.

Hi @jeremyjpj0916,

I should have mentioned that it works

that I want to upstream via


Try adjusting your service to something more like this:

//------ Create Service------//
curl -i -X POST --url http://localhost:8001/services --data “name=VehicleDataQueryService” --data “protocol=https” --data “host=localhost” --data “port=5077” --data-urlencode “path=/v1/vehicle/makes”

See if that helps, although I would think router URI would -> tack onto the end of your service backend URL by default.


I have one service hosted locally with port 5077 with resouce url is /v1/aaa/bbbb

Now I want Kong to run locally and route the request to the above up steam url.

Can you share example.

I tried from doc but not succeeded


I have the same issue.
any solution to test kong on localhost?
i raised topic here Connect() failed (111: Connection refused) while connecting to upstream
but no success