Probe for open application on a TCP port
First, I'd suggest to improve on naming. checkAppPr doesn't really tell me anything about what this function does. Naming it to checkAppPort would make more sense.

Next, you've got some hard-coded literals in your code like 127.0.0.1, 20, 1000. Without some sensible names, they don't mean anything. Put them in constants along with the convention of using capital letters and underscores as names.

Your code is an example of one function trying to jam too much functionality. You can split this into two functions, one that checks for any port and resolves/rejects, and another function that repeatedly calls the first one. You've done it already, except the function is nested in the other.

Here's my take on your code. Longer, but splits out responsibilities.

// Returns a promise that resolves when the port is open
checkPortStatus: function(port, host){
  return new Promise((resolve, reject) =&gt; {
    portscanner.checkPortStatus(port, host, function(error, status) {
      if(error)
        reject(error);
      else if(status === 'open')
        resolve(status);
      else
        reject(new Error('Port is not open'));
    });
  });
},

// Your API function
checkAppPort: function(port, retriesLeft) {

  const TIME_BETWEEN_CHECKS = 1000;
  const HOST = '127.0.0.1';
  const RETRIES = 20;

  // Setting a default to retriesLeft
  retriesLeft = retriesLeft === void 0 ? RETRIES : retriesLeft;

  if(!port) throw new Error('Port is required');
  if(retriesLeft === 0) return Promise.reject('Timed Out');

  return new Promise((resolve, reject) =&gt; {

    // We call our checker. When it resolves, it calls this promise's resolve.
    // If it rejects, we do added work.
    this.checkPortStatus(port, host).then(resolve, error =&gt; {
      setTimeout(() =&gt; {

        // Call this function again, with one less retry. However, we hook our
        // resolve and reject to the promise of the new call effectively making
        // a chain when it keeps failing.
        this.checkAppPort(port, retriesLeft - 1).then(resolve, reject);

      }, TIME_BETWEEN_CHECKS);
    });
  });
}