Home
Support Forums

Fetch error during build "getaddrinfo EAI_AGAI"

My 11ty based site https://www.bigbadcon.com is suddenly having issues during the build step. It runs a node-fetch for content during the build step. This fetch worked fine yesterday and today is failing with “getaddrinfo EAI_AGAI” error. I tried the exact same deploy as yesterday and it still fails. It works fine when I am building locally using netlify-cli, so I know the API that I am hitting is fine.

Here is my build log:

8:54:59 AM: Build ready to start
8:55:01 AM: build-image version: c6001ed68662a13e5deb24abec2b46058c58248a
8:55:01 AM: build-image tag: v3.9.0
8:55:01 AM: buildbot version: fd60e21d56897195475b3dbb3e1c495894eb873c
8:55:01 AM: Fetching cached dependencies
8:55:01 AM: Starting to download cache of 547.6MB
8:55:03 AM: Finished downloading cache in 2.614001078s
8:55:03 AM: Starting to extract cache
8:55:11 AM: Finished extracting cache in 7.571542671s
8:55:11 AM: Finished fetching cache in 10.282648417s
8:55:11 AM: Starting to prepare the repo for build
8:55:12 AM: Preparing Git Reference refs/heads/main
8:55:15 AM: Parsing package.json dependencies
8:55:15 AM: Different functions path detected, going to use the one specified in the Netlify configuration file: 'functions' versus '' in the Netlify UI
8:55:16 AM: Starting build script
8:55:16 AM: Installing dependencies
8:55:16 AM: Python version set to 2.7
8:55:16 AM: Started restoring cached node version
8:55:19 AM: Finished restoring cached node version
8:55:19 AM: v12.18.0 is already installed.
8:55:20 AM: Now using node v12.18.0 (npm v6.14.4)
8:55:20 AM: Started restoring cached build plugins
8:55:20 AM: Finished restoring cached build plugins
8:55:20 AM: Attempting ruby version 2.7.1, read from environment
8:55:21 AM: Started restoring cached ruby version
8:55:21 AM: Finished restoring cached ruby version
8:55:23 AM: Using ruby version 2.7.1
8:55:24 AM: Using PHP version 5.6
8:55:24 AM: Started restoring cached node modules
8:55:24 AM: Finished restoring cached node modules
8:55:24 AM: Started restoring cached go cache
8:55:24 AM: Finished restoring cached go cache
8:55:24 AM: go version go1.14.4 linux/amd64
8:55:24 AM: go version go1.14.4 linux/amd64
8:55:24 AM: Installing missing commands
8:55:24 AM: Verify run directory
8:55:26 AM: ​
8:55:26 AM: ────────────────────────────────────────────────────────────────
8:55:26 AM:   Netlify Build                                                 
8:55:26 AM: ────────────────────────────────────────────────────────────────
8:55:26 AM: ​
8:55:26 AM: ❯ Version
8:55:26 AM:   @netlify/build 18.7.2
8:55:26 AM: ​
8:55:26 AM: ❯ Flags
8:55:26 AM:   baseRelDir: true
8:55:26 AM:   buildId: 612fa253c4f1421768bbd527
8:55:26 AM:   deployId: 612fa253c4f1421768bbd529
8:55:26 AM: ​
8:55:26 AM: ❯ Current directory
8:55:26 AM:   /opt/build/repo
8:55:26 AM: ​
8:55:26 AM: ❯ Config file
8:55:26 AM:   /opt/build/repo/netlify.toml
8:55:26 AM: ​
8:55:26 AM: ❯ Context
8:55:26 AM:   production
8:55:26 AM: ​
8:55:26 AM: ────────────────────────────────────────────────────────────────
8:55:26 AM:   1. build.command from netlify.toml                            
8:55:26 AM: ────────────────────────────────────────────────────────────────
8:55:26 AM: ​
8:55:26 AM: $ npm run build
8:55:26 AM: > bbc-11ty@0.0.2 build /opt/build/repo
8:55:26 AM: > cross-env ELEVENTY_ENV=prod eleventy
8:55:33 AM: FetchError: request to https://admin.bigbadcon.com:8091/api/events/all/public failed, reason: getaddrinfo EAI_AGAIN admin.bigbadcon.com
8:55:33 AM:     at ClientRequest.<anonymous> (/opt/build/repo/node_modules/node-fetch/lib/index.js:1461:11)
8:55:33 AM:     at ClientRequest.emit (events.js:315:20)
8:55:33 AM:     at TLSSocket.socketErrorListener (_http_client.js:426:9)
8:55:33 AM:     at TLSSocket.emit (events.js:315:20)
8:55:33 AM:     at emitErrorNT (internal/streams/destroy.js:92:8)
8:55:33 AM:     at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
8:55:33 AM:     at processTicksAndRejections (internal/process/task_queues.js:84:21) {
8:55:33 AM:   type: 'system',
8:55:33 AM:   errno: 'EAI_AGAIN',
8:55:33 AM:   code: 'EAI_AGAIN'
8:55:33 AM: }
8:55:33 AM: warn - You have enabled the JIT engine which is currently in preview.
8:55:33 AM: warn - Preview features are not covered by semver, may introduce breaking changes, and can change at any time.
8:55:35 AM: Problem writing Eleventy templates: (more in DEBUG output)
8:55:35 AM: > Could not resolve pagination key in template data: eventData.events
8:55:35 AM: `Error` was thrown:
8:55:35 AM:     Error: Could not resolve pagination key in template data: eventData.events
8:55:35 AM:         at Pagination._resolveItems (/opt/build/repo/node_modules/@11ty/eleventy/src/Plugins/Pagination.js:102:13)
8:55:35 AM:         at Pagination.setData (/opt/build/repo/node_modules/@11ty/eleventy/src/Plugins/Pagination.js:65:24)
8:55:35 AM:         at new Pagination (/opt/build/repo/node_modules/@11ty/eleventy/src/Plugins/Pagination.js:13:10)
8:55:35 AM:         at Template.getTemplates (/opt/build/repo/node_modules/@11ty/eleventy/src/Template.js:494:21)
8:55:35 AM:         at TemplateMap.initDependencyMap (/opt/build/repo/node_modules/@11ty/eleventy/src/TemplateMap.js:246:41)
8:55:35 AM:         at runMicrotasks (<anonymous>)
8:55:35 AM:         at processTicksAndRejections (internal/process/task_queues.js:97:5)
8:55:35 AM:         at async TemplateMap.cache (/opt/build/repo/node_modules/@11ty/eleventy/src/TemplateMap.js:279:5)
8:55:35 AM:         at async TemplateWriter._createTemplateMap (/opt/build/repo/node_modules/@11ty/eleventy/src/TemplateWriter.js:170:5)
8:55:35 AM:         at async TemplateWriter.writeTemplates (/opt/build/repo/node_modules/@11ty/eleventy/src/TemplateWriter.js:203:5)
8:55:35 AM: Benchmark (Data): `./src/_data/eventData.js` took 6115ms (69.5%)
8:55:35 AM: Benchmark (Data): `./src/_data/tailwindcss.js` took 1440ms (16.4%)
8:55:35 AM: Copied 35 files / Wrote 0 files in 8.55 seconds (v0.12.1)
8:55:36 AM: npm ERR! code ELIFECYCLE
8:55:36 AM: npm ERR! errno 1
8:55:36 AM: npm ERR! bbc-11ty@0.0.2 build: `cross-env ELEVENTY_ENV=prod eleventy`
8:55:36 AM: npm ERR! Exit status 1
8:55:36 AM: npm ERR!
8:55:36 AM: npm ERR! Failed at the bbc-11ty@0.0.2 build script.
8:55:36 AM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
8:55:36 AM: npm ERR! A complete log of this run can be found in:
8:55:36 AM: npm ERR!     /opt/buildhome/.npm/_logs/2021-09-01T15_55_36_003Z-debug.log
8:55:36 AM: ​
8:55:36 AM: ────────────────────────────────────────────────────────────────
8:55:36 AM:   "build.command" failed                                        
8:55:36 AM: ────────────────────────────────────────────────────────────────
8:55:36 AM: ​
8:55:36 AM:   Error message
8:55:36 AM:   Command failed with exit code 1: npm run build
8:55:36 AM: ​
8:55:36 AM:   Error location
8:55:36 AM:   In build.command from netlify.toml:
8:55:36 AM:   npm run build
8:55:36 AM: ​
8:55:36 AM:   Resolved config
8:55:36 AM:   build:
8:55:36 AM:     base: /opt/build/repo
8:55:36 AM:     command: npm run build
8:55:36 AM:     commandOrigin: config
8:55:36 AM:     environment:
8:55:36 AM:       - GOOGLE_PRIVATE_KEY
8:55:36 AM:       - GOOGLE_SERVICE_ACCOUNT_EMAIL
8:55:36 AM:       - GOOGLE_SHEET_REGISTER_BIGBADONLINE
8:55:36 AM:       - NETLIFY_BUILD_HOOK_SLACKBOT
8:55:36 AM:       - SENDGRID_API_KEY
8:55:36 AM:       - SLACK_BOT_TOKEN
8:55:36 AM:       - SLACK_SIGNING_SECRET
8:55:36 AM:       - NODE_ENV
8:55:36 AM:     publish: /opt/build/repo/dist
8:55:36 AM:     publishOrigin: config
8:55:36 AM:   functions:
8:55:36 AM:     submission-created:
8:55:36 AM:       included_files:
8:55:36 AM:         - certs/bigbadcon-com-chain.pem
8:55:36 AM:   functionsDirectory: /opt/build/repo/functions
8:55:36 AM: Caching artifacts
8:55:36 AM: Started saving node modules
8:55:36 AM: Finished saving node modules
8:55:36 AM: Started saving build plugins
8:55:36 AM: Finished saving build plugins
8:55:36 AM: Started saving pip cache
8:55:36 AM: Finished saving pip cache
8:55:36 AM: Started saving emacs cask dependencies
8:55:36 AM: Finished saving emacs cask dependencies
8:55:36 AM: Started saving maven dependencies
8:55:36 AM: Finished saving maven dependencies
8:55:36 AM: Started saving boot dependencies
8:55:36 AM: Finished saving boot dependencies
8:55:36 AM: Started saving rust rustup cache
8:55:36 AM: Finished saving rust rustup cache
8:55:36 AM: Started saving go dependencies
8:55:36 AM: Finished saving go dependencies
8:55:36 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
8:55:36 AM: Creating deploy upload records
8:55:36 AM: Failing build: Failed to build site
8:55:36 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2
8:55:36 AM: Finished processing build request in 35.607529224s

Hi @colinaut

If you are using Firebase javascript - What's the source of Error: getaddrinfo EAI_AGAIN? - Stack Overflow may help.

Otherwise The getaddrinfo EAI_AGAIN error again · Issue #15780 · nodejs/node · GitHub

There is no single solution because it entirely depends on why the DNS server sends that back.

This Coding Defined post has a little more information NodeJS Error - errno EAI_AGAIN - Coding Defined

I’m not using Firebase. It’s an API server built by another on our team. I did the same googling as you have linked here. I realize it’s some sort of DNS error but that doesn’t really help me. As I said when run a build locally it works. It only fails when I try to deploy/build on Netlify. It was working fine yesterday. Nothing has changed — not my eleventy code, nor the server that hosts the API. The only change is that Netlify builds fail.

I just tried another deploy and the problem seems to have fixed itself. Not sure what it was as I didn’t make any changes