java.net.ConnectException: Connection refused (Connection refused) when posting to http://localhost:8080/

asifnoor
Kilo Patron

Hi,

i have an api running on localhost:8080 port and it is working fine when i access on browser.

I created an REST API and trying to connect with that, but i am getting the following error.

Tried the sample code in background script.
var sm = new sn_ws.RESTMessageV2();
sm.setEndpoint("http://localhost:8080/");
sm.setHttpMethod("get");
sm.execute();

java.net.ConnectException: Connection refused (Connection refused) when posting to http://localhost:8080/

Any idea what might be the issue?

1 ACCEPTED SOLUTION

The Machine
Kilo Sage

Localhost is local to your machine/network and not publicly available to cloud platforms like ServiceNow.

What you need to do is setup a MID server on that machine, and then set the MID Server in your REST call.

View solution in original post

3 REPLIES 3

The Machine
Kilo Sage

Localhost is local to your machine/network and not publicly available to cloud platforms like ServiceNow.

What you need to do is setup a MID server on that machine, and then set the MID Server in your REST call.

dev115415
Tera Expert

could you please elaborate where to setup MID server- on servicenow or my local machine. Also how to do it?

GB14
Kilo Patron

@asifnoor  Were you able to solve this? Can you please share the resolution? 
Thanks