REST API failure with error java.net.ConnectException: Connection refused (Connection refused)

Smith Johnson
Tera Guru

Hello,

I have the following REST call to localhost, but I receive the following error. 

 

SmithJohnson_0-1669968875638.png


If I do this call from Postman, everything works as expected.

 

Any ideas on how to handle this?

3 REPLIES 3

Nayan  Dhamane
Kilo Sage
Kilo Sage

Hello @Smith Johnson ,

 

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.

 

Please mark as correct.
BR,
Nayan

If my answer solved your issue, please mark my answer as Correct & Helpful based on the Impact

Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.

Appli
Mega Sage
Mega Sage

Hi, do you send outbound REST message through a MID server? Is web service running on MID server as well?

Hope it helps

SanjivMeher
Kilo Patron
Kilo Patron

Did you do a firewall check from you localhost to servicenow?

There may be a firewall block and you may need to use a midserver in your rest api to make it work.


Please mark this response as correct or helpful if it assisted you with your question.