newbiedev
newbiedev

Reputation: 3566

axios post requests - Error: getaddrinfo ENOTFOUND

I'm using axios inside a cli node script. I've noticed that sometimes inside the console this error will be logged:

Error: getaddrinfo ENOTFOUND www.foobar.com
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:67:26) {
  errno: -3008,
  code: 'ENOTFOUND',

It will be handled by the .catch() function and the next axios request to the same address will continue work and I get 200 status code. Is there any reason that cause that a axios.post request can generate that error?

Upvotes: 6

Views: 13121

Answers (1)

Kerem
Kerem

Reputation: 888

As @Javapocalypse commented, you should add http:// beginning of your url.

Upvotes: 2

Related Questions