function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
*rdinakaran**rdinakaran* 

Connect Localhost from Apex

Hi Devs,

 

I want to connect with my localhost .for that i use "http:localhost:9000" in htpprequest in apex. It shows service unavailable error.

Apex is run in salesforce server ,so it doesnt any response to me.

 

Is there any other way to do this.

 

Please help regarding this.

 

 

//My Http request 

Http http  = new Http(); 
        HttpRequest req = new HttpRequest(); 
        req.setEndpoint('http://localhost:9000'); 
        req.setMethod('GET');
        req.setTimeout(50000);
        req.setbody(xmlStringxmlRD);
        HttpResponse res = http.send(req); 
        system.debug('&&&&res'+res);

 

my Debug log show as

 

&&&&resSystem.HttpResponse[Status=Service Unavailable, StatusCode=503]

 

 

MiddhaMiddha

You are trying to initiate a call from salesforce (publicly hosted) to your local machine (which does not have any public existence). You can only make calls to public IPs from salesforce.

Rad ElhageRad Elhage
Have you found a way to make this work? I am tryung to do the same. 
SidharthSidharth
Trying to do the same, and getting the same error. Any workaround to achieve this ? Thanks.