REST API failure with error java.net.ConnectException: Connection refused (Connection refused)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2022 12:15 AM
Hello,
I have the following REST call to localhost, but I receive the following error.
If I do this call from Postman, everything works as expected.
Any ideas on how to handle this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2022 12:35 AM
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
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2022 10:34 AM
Hi, do you send outbound REST message through a MID server? Is web service running on MID server as well?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2022 11:04 AM
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.