Search code examples
localhostwebservertally

Access localhost from web application


I have a software (Tally) running in my local machine. This software can run as a server (http://localhost, port number 9000). API call can be made using this URL to import and export data. Can I make a http request to this localserver from my application running in a remote webserver.

I tried to do it like this from the webserver:

var request = require('request');
var options = {
    uri: 'http://192.168.0.3:9000',
    method: 'GET'
};
request(options, function (error, response, body) {
    if (error) {
        console.log("Invalid Network Details");
    } else {
        if (response.statusCode == 200) {
            console.log(body);
        } else {
            console.log("Unauthorized Access!!");
        }
    }
});

I am getting an output "Invalid network Details"


Solution

  • I don't know about tally application, BUT in my opinion, you should open the 9000 port in the firewall (and in your router if your webserver is in a different network). In your application, instead of using http://localhost in the remote webserver you have to use the the ip of your local machine (if you are in the same network) or the public address of your local machine (if your computer and your webserver are on diferent networks).

    PD. your public address usually changes every x time (could be a dayor could be a month) so I would use noip o something like.