最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - axios post requests - Error: getaddrinfo ENOTFOUND - Stack Overflow

programmeradmin2浏览0评论

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
    at GetAddrInfoReqWrap.onlookup [as onplete] (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?

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.
    at GetAddrInfoReqWrap.onlookup [as onplete] (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?

Share Improve this question asked Apr 9, 2021 at 6:31 newbiedevnewbiedev 3,5965 gold badges28 silver badges83 bronze badges 2
  • 2 Try adding http:// before your url – Javapocalypse Commented Apr 9, 2021 at 22:58
  • I am facing the same error, Can you please post your code so that it helps others? – s d Commented Dec 16, 2022 at 13:19
Add a ment  | 

1 Answer 1

Reset to default 2

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

发布评论

评论列表(0)

  1. 暂无评论