Node + Pokeapi "Error: connect ECONNREFUSED 127.0.0.1:443"

Asked

Viewed 1,062 times

1

I’m new to the world of Nodejs, I’d like to know why I can’t test the most basic document algorithm https://github.com/PokeAPI/pokedex-promise-v2

my code is like this:

var Pokedex = require('pokedex-promise-v2');
var options = {
  protocol: 'https',
  hostName: 'localhost:443',
  versionPath: '/api/v2/',
  cacheLimit: 100 * 1000, // 100s
  tiemout: 5 * 1000 // 5s
}
var P = new Pokedex(options);
 P.getBerryByName('cheri')
    .then(function(response) {
      console.log(response);
    })
    .catch(function(error) {
      console.log('There was an ERROR: ', error);
    });

2 answers

1

This error usually occurs when the used port is already in use. Run the command below to check who is using the port.

$ netstat -lant | grep ":443" 
  • 1

    works in windows? I tried here and it was not.

  • 1

    It doesn’t work on Windows. This is a Linux/Unix command. But what Teliz answered there is true. If removing the whole line of the options variable works, but in doing so it points by default to an external url url: 'http://pokeapi.co/api/v2/type/10/'

1

From what I’ve seen of your json options is in trouble. try:

var options = { protocol: 'https', hostName: 'pokeapi.co', versionPath: '/api/v2/' }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.