'Failed to fetch error while running gatsby develop or gatsby build

So basically i have a gatsby website with drupal rest. To run it on the local machine, i use docker with docksal. And sometimes (1 time per 5), when i run gatsby develop or gatsby build i get the next error:

info Starting to fetch data from Drupal

 ERROR 

Failed to fetch http://[sitename].docksal/api/block_content/reviews getaddrinfo ENOTFOUND [sitename].docksal

⠀

 ERROR #11321  PLUGIN

"gatsby-source-drupal" threw an error while running the sourceNodes lifecycle:

getaddrinfo ENOTFOUND [sitename].docksal



  Error: getaddrinfo ENOTFOUND [sitename].docksal

not finished source and transform nodes - 1.221s
not finished Fetch data from Drupal - 1.134s
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [sitename]@0.1.0 build: `npx gatsby build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [sitename]@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/***/.npm/_logs/2022-05-16T12_46_42_956Z-debug.log

But when i run the command again everything is fine. So this error happens to me with no reason, and in 100% times it is fixed with running the same command again.

But maybe someone knows, how can i get rid of this error completely, because it is annoying!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source