Build Error ENOTFOUND

Netlify site name: enfu-fe.netlify.app
I have a nextjs page that cant be built and the errors are a lot of these (for many pages that called the REST API):

FetchError: request to https://services.enfution.com/api/config failed, reason: getaddrinfo ENOTFOUND services.enfution.com

It’s super bizzare because https://services.enfution.com/api/config is totally accessible. It’s even accessible thru my local environment and runs fine. I reaaallly really don’t know what the problem is here and I’d really appreciate any help.

Full build log:

2:49:56 AM: Build ready to start
2:49:57 AM: build-image version: a49edbc55fc722f80f6b85963a5060f8d043a844 (focal)
2:49:57 AM: build-image tag: v4.8.1
2:49:57 AM: buildbot version: f89dd42aa70d76d1da992dc3fa004a4c745208bc
2:49:57 AM: Fetching cached dependencies
2:49:57 AM: Failed to fetch cache, continuing with build
2:49:57 AM: Starting to prepare the repo for build
2:49:58 AM: No cached dependencies found. Cloning fresh repo
2:49:58 AM: git clone https://github.com/Three-Sigma-Technologies/enfu-2022-frontend
2:49:58 AM: Preparing Git Reference refs/heads/main
2:49:58 AM: Parsing package.json dependencies
2:49:59 AM: Starting build script
2:50:00 AM: Installing dependencies
2:50:00 AM: Python version set to 2.7
2:50:00 AM: v16.15.1 is already installed.
2:50:01 AM: Now using node v16.15.1 (npm v8.11.0)
2:50:01 AM: Started restoring cached build plugins
2:50:01 AM: Finished restoring cached build plugins
2:50:01 AM: Attempting ruby version 2.7.2, read from environment
2:50:02 AM: Using ruby version 2.7.2
2:50:02 AM: Using PHP version 8.0
2:50:02 AM: No npm workspaces detected
2:50:02 AM: Started restoring cached node modules
2:50:02 AM: Finished restoring cached node modules
2:50:03 AM: Installing NPM modules using NPM version 8.11.0
2:50:03 AM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
2:50:03 AM: npm WARN config location in the cache, and they are managed by
2:50:03 AM: npm WARN config     [`cacache`](http://npm.im/cacache).
2:50:03 AM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
2:50:03 AM: npm WARN config location in the cache, and they are managed by
2:50:03 AM: npm WARN config     [`cacache`](http://npm.im/cacache).
2:50:04 AM: npm WARN ERESOLVE overriding peer dependency
2:50:04 AM: npm WARN While resolving: @react-aria/ssr@3.1.2
2:50:04 AM: npm WARN Found: react@18.1.0
2:50:04 AM: npm WARN node_modules/react
2:50:04 AM: npm WARN   react@"18.1.0" from the root project
2:50:04 AM: npm WARN   12 more (@restart/hooks, @restart/ui, next, prop-types-extra, ...)
2:50:04 AM: npm WARN
2:50:04 AM: npm WARN Could not resolve dependency:
2:50:04 AM: npm WARN peer react@"^16.8.0 || ^17.0.0-rc.1" from @react-aria/ssr@3.1.2
2:50:04 AM: npm WARN node_modules/@restart/ui/node_modules/@react-aria/ssr
2:50:04 AM: npm WARN   @react-aria/ssr@"^3.0.1" from @restart/ui@1.2.0
2:50:04 AM: npm WARN   node_modules/@restart/ui
2:50:04 AM: npm WARN
2:50:04 AM: npm WARN Conflicting peer dependency: react@17.0.2
2:50:04 AM: npm WARN node_modules/react
2:50:04 AM: npm WARN   peer react@"^16.8.0 || ^17.0.0-rc.1" from @react-aria/ssr@3.1.2
2:50:04 AM: npm WARN   node_modules/@restart/ui/node_modules/@react-aria/ssr
2:50:04 AM: npm WARN     @react-aria/ssr@"^3.0.1" from @restart/ui@1.2.0
2:50:04 AM: npm WARN     node_modules/@restart/ui
2:50:14 AM: added 447 packages, and audited 448 packages in 10s
2:50:14 AM: 76 packages are looking for funding
2:50:14 AM:   run `npm fund` for details
2:50:14 AM: found 0 vulnerabilities
2:50:14 AM: NPM modules installed
2:50:14 AM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
2:50:14 AM: npm WARN config location in the cache, and they are managed by
2:50:14 AM: npm WARN config     [`cacache`](http://npm.im/cacache).
2:50:14 AM: Started restoring cached go cache
2:50:14 AM: Finished restoring cached go cache
2:50:14 AM: Installing Go version 1.17 (requested 1.17)
2:50:19 AM: unset GOOS;
2:50:19 AM: unset GOARCH;
2:50:19 AM: export GOROOT='/opt/buildhome/.gimme/versions/go1.17.linux.amd64';
2:50:19 AM: export PATH="/opt/buildhome/.gimme/versions/go1.17.linux.amd64/bin:${PATH}";
2:50:19 AM: go version >&2;
2:50:19 AM: export GIMME_ENV="/opt/buildhome/.gimme/env/go1.17.linux.amd64.env"
2:50:19 AM: go version go1.17 linux/amd64
2:50:19 AM: Installing missing commands
2:50:19 AM: Verify run directory
2:50:21 AM: ​
2:50:21 AM: ────────────────────────────────────────────────────────────────
2:50:21 AM:   Netlify Build                                                 
2:50:21 AM: ────────────────────────────────────────────────────────────────
2:50:21 AM: ​
2:50:21 AM: ❯ Version
2:50:21 AM:   @netlify/build 27.1.5
2:50:21 AM: ​
2:50:21 AM: ❯ Flags
2:50:21 AM:   baseRelDir: true
2:50:21 AM:   buildId: 62b115b4b37d4a400499cb7d
2:50:21 AM:   deployId: 62b115b4b37d4a400499cb7f
2:50:21 AM: ​
2:50:21 AM: ❯ Current directory
2:50:21 AM:   /opt/build/repo
2:50:21 AM: ​
2:50:21 AM: ❯ Config file
2:50:21 AM:   No config file was defined: using default values.
2:50:21 AM: ​
2:50:21 AM: ❯ Context
2:50:21 AM:   production
2:50:21 AM: ​
2:50:21 AM: ❯ Installing plugins
2:50:21 AM:    - @netlify/plugin-nextjs@4.9.1
2:50:33 AM: ​
2:50:33 AM: ❯ Loading plugins
2:50:33 AM:    - @netlify/plugin-nextjs@4.9.1 from Netlify app
2:50:34 AM: ​
2:50:34 AM: ────────────────────────────────────────────────────────────────
2:50:34 AM:   1. @netlify/plugin-nextjs (onPreBuild event)                  
2:50:34 AM: ────────────────────────────────────────────────────────────────
2:50:34 AM: ​
2:50:34 AM: No Next.js cache to restore.
2:50:34 AM: Netlify configuration property "build.environment.NEXT_PRIVATE_TARGET" value changed.
2:50:34 AM: ​
2:50:34 AM: (@netlify/plugin-nextjs onPreBuild completed in 21ms)
2:50:34 AM: ​
2:50:34 AM: ────────────────────────────────────────────────────────────────
2:50:34 AM:   2. Build command from Netlify app                             
2:50:34 AM: ────────────────────────────────────────────────────────────────
2:50:34 AM: ​
2:50:34 AM: $ npm run build
2:50:35 AM: npm WARN config tmp This setting is no longer used.  npm stores temporary files in a special
2:50:35 AM: npm WARN config location in the cache, and they are managed by
2:50:35 AM: npm WARN config     [`cacache`](http://npm.im/cacache).
2:50:35 AM: > enfu-fe@0.1.0 build
2:50:35 AM: > next build
2:50:35 AM: warn  - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
2:50:35 AM: info  - Checking validity of types...
2:50:39 AM: info  - Creating an optimized production build...
2:50:39 AM: info  - Disabled SWC as replacement for Babel because of custom Babel configuration ".babelrc" https://nextjs.org/docs/messages/swc-disabled
2:50:40 AM: info  - Using external babel configuration from /opt/build/repo/.babelrc
2:51:22 AM: info  - Compiled successfully
2:51:22 AM: info  - Collecting page data...
2:51:26 AM: info  - Generating static pages (0/17)
2:51:26 AM: info  - Generating static pages (4/17)
2:51:26 AM: Error occurred prerendering page "/national-seminar/register". Read more: https://nextjs.org/docs/messages/prerender-error
2:51:26 AM: FetchError: request to https://services.enfution.com/api/config failed, reason: getaddrinfo ENOTFOUND services.enfution.com
2:51:26 AM:     at ClientRequest.<anonymous> (/opt/build/repo/node_modules/next/dist/compiled/node-fetch/index.js:1:64142)
2:51:26 AM:     at ClientRequest.emit (node:events:527:28)
2:51:26 AM:     at TLSSocket.socketErrorListener (node:_http_client:454:9)
2:51:26 AM:     at TLSSocket.emit (node:events:527:28)
2:51:26 AM:     at emitErrorNT (node:internal/streams/destroy:157:8)
2:51:26 AM:     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
2:51:26 AM:     at processTicksAndRejections (node:internal/process/task_queues:83:21)
2:51:26 AM: info  - Generating static pages (8/17)
2:51:26 AM: Error occurred prerendering page "/dbcc/register/coaching-session". Read more: https://nextjs.org/docs/messages/prerender-error
2:51:26 AM: FetchError: request to https://services.enfution.com/api/config failed, reason: getaddrinfo ENOTFOUND services.enfution.com
2:51:26 AM:     at ClientRequest.<anonymous> (/opt/build/repo/node_modules/next/dist/compiled/node-fetch/index.js:1:64142)
2:51:26 AM:     at ClientRequest.emit (node:events:527:28)
2:51:26 AM:     at TLSSocket.socketErrorListener (node:_http_client:454:9)
2:51:26 AM:     at TLSSocket.emit (node:events:527:28)
2:51:26 AM:     at emitErrorNT (node:internal/streams/destroy:157:8)
2:51:26 AM:     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
2:51:26 AM:     at processTicksAndRejections (node:internal/process/task_queues:83:21)
2:51:26 AM: Error occurred prerendering page "/dbcc/register/coaching-clinic". Read more: https://nextjs.org/docs/messages/prerender-error
2:51:26 AM: FetchError: request to https://services.enfution.com/api/config failed, reason: getaddrinfo ENOTFOUND services.enfution.com
2:51:26 AM:     at ClientRequest.<anonymous> (/opt/build/repo/node_modules/next/dist/compiled/node-fetch/index.js:1:64142)
2:51:26 AM:     at ClientRequest.emit (node:events:527:28)
2:51:26 AM:     at TLSSocket.socketErrorListener (node:_http_client:454:9)
2:51:26 AM:     at TLSSocket.emit (node:events:527:28)
2:51:26 AM:     at emitErrorNT (node:internal/streams/destroy:157:8)
2:51:26 AM:     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
2:51:26 AM:     at processTicksAndRejections (node:internal/process/task_queues:83:21)
2:51:26 AM: Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
2:51:26 AM: FetchError: request to https://services.enfution.com/api/config failed, reason: getaddrinfo ENOTFOUND services.enfution.com
2:51:26 AM:     at ClientRequest.<anonymous> (/opt/build/repo/node_modules/next/dist/compiled/node-fetch/index.js:1:64142)
2:51:26 AM:     at ClientRequest.emit (node:events:527:28)
2:51:26 AM:     at TLSSocket.socketErrorListener (node:_http_client:454:9)
2:51:26 AM:     at TLSSocket.emit (node:events:527:28)
2:51:26 AM:     at emitErrorNT (node:internal/streams/destroy:157:8)
2:51:26 AM:     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
2:51:26 AM:     at processTicksAndRejections (node:internal/process/task_queues:83:21)
2:51:26 AM: info  - Generating static pages (12/17)
2:51:26 AM: Error occurred prerendering page "/dbcc/register". Read more: https://nextjs.org/docs/messages/prerender-error
2:51:26 AM: FetchError: request to https://services.enfution.com/api/config failed, reason: getaddrinfo ENOTFOUND services.enfution.com
2:51:26 AM:     at ClientRequest.<anonymous> (/opt/build/repo/node_modules/next/dist/compiled/node-fetch/index.js:1:64142)
2:51:26 AM:     at ClientRequest.emit (node:events:527:28)
2:51:26 AM:     at TLSSocket.socketErrorListener (node:_http_client:454:9)
2:51:26 AM:     at TLSSocket.emit (node:events:527:28)
2:51:26 AM:     at emitErrorNT (node:internal/streams/destroy:157:8)
2:51:28 AM: Creating deploy upload records
2:51:26 AM:     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
2:51:26 AM:     at processTicksAndRejections (node:internal/process/task_queues:83:21)
2:51:26 AM: Error occurred prerendering page "/dbcc/register/dbcc". Read more: https://nextjs.org/docs/messages/prerender-error
2:51:26 AM: FetchError: request to https://services.enfution.com/api/config failed, reason: getaddrinfo ENOTFOUND services.enfution.com
2:51:26 AM:     at ClientRequest.<anonymous> (/opt/build/repo/node_modules/next/dist/compiled/node-fetch/index.js:1:64142)
2:51:28 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
2:51:26 AM:     at ClientRequest.emit (node:events:527:28)
2:51:26 AM:     at TLSSocket.socketErrorListener (node:_http_client:454:9)
2:51:26 AM:     at TLSSocket.emit (node:events:527:28)
2:51:26 AM:     at emitErrorNT (node:internal/streams/destroy:157:8)
2:51:26 AM:     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
2:51:26 AM:     at processTicksAndRejections (node:internal/process/task_queues:83:21)
2:51:26 AM: Error occurred prerendering page "/national-seminar/register/national-seminar". Read more: https://nextjs.org/docs/messages/prerender-error
2:51:26 AM: FetchError: request to https://services.enfution.com/api/config failed, reason: getaddrinfo ENOTFOUND services.enfution.com
2:51:26 AM:     at ClientRequest.<anonymous> (/opt/build/repo/node_modules/next/dist/compiled/node-fetch/index.js:1:64142)
2:51:26 AM:     at ClientRequest.emit (node:events:527:28)
2:51:26 AM:     at TLSSocket.socketErrorListener (node:_http_client:454:9)
2:51:26 AM:     at TLSSocket.emit (node:events:527:28)
2:51:26 AM:     at emitErrorNT (node:internal/streams/destroy:157:8)
2:51:26 AM:     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
2:51:26 AM:     at processTicksAndRejections (node:internal/process/task_queues:83:21)
2:51:26 AM: Error occurred prerendering page "/national-seminar/register/sharing-session". Read more: https://nextjs.org/docs/messages/prerender-error
2:51:26 AM: FetchError: request to https://services.enfution.com/api/config failed, reason: getaddrinfo ENOTFOUND services.enfution.com
2:51:26 AM:     at ClientRequest.<anonymous> (/opt/build/repo/node_modules/next/dist/compiled/node-fetch/index.js:1:64142)
2:51:26 AM:     at ClientRequest.emit (node:events:527:28)
2:51:26 AM:     at TLSSocket.socketErrorListener (node:_http_client:454:9)
2:51:26 AM:     at TLSSocket.emit (node:events:527:28)
2:51:26 AM:     at emitErrorNT (node:internal/streams/destroy:157:8)
2:51:26 AM:     at emitErrorCloseNT (node:internal/streams/destroy:122:3)
2:51:26 AM:     at processTicksAndRejections (node:internal/process/task_queues:83:21)
2:51:26 AM: info  - Generating static pages (17/17)
2:51:26 AM: > Build error occurred
2:51:26 AM: Error: Export encountered errors on following paths:
2:51:26 AM: 	/
2:51:26 AM: 	/dbcc/register
2:51:26 AM: 	/dbcc/register/coaching-clinic
2:51:26 AM: 	/dbcc/register/coaching-session
2:51:26 AM: 	/dbcc/register/dbcc
2:51:26 AM: 	/national-seminar/register
2:51:26 AM: 	/national-seminar/register/national-seminar
2:51:26 AM: 	/national-seminar/register/sharing-session
2:51:26 AM:     at /opt/build/repo/node_modules/next/dist/export/index.js:398:19
2:51:26 AM:     at runMicrotasks (<anonymous>)
2:51:26 AM:     at processTicksAndRejections (node:internal/process/task_queues:96:5)
2:51:26 AM:     at async Span.traceAsyncFn (/opt/build/repo/node_modules/next/dist/trace/trace.js:79:20)
2:51:26 AM:     at async /opt/build/repo/node_modules/next/dist/build/index.js:1034:21
2:51:26 AM:     at async Span.traceAsyncFn (/opt/build/repo/node_modules/next/dist/trace/trace.js:79:20)
2:51:26 AM:     at async /opt/build/repo/node_modules/next/dist/build/index.js:910:17
2:51:26 AM:     at async Span.traceAsyncFn (/opt/build/repo/node_modules/next/dist/trace/trace.js:79:20)
2:51:26 AM:     at async Object.build [as default] (/opt/build/repo/node_modules/next/dist/build/index.js:58:29)
2:51:26 AM: ​
2:51:26 AM: ────────────────────────────────────────────────────────────────
2:51:26 AM:   "build.command" failed                                        
2:51:26 AM: ────────────────────────────────────────────────────────────────
2:51:26 AM: ​
2:51:26 AM:   Error message
2:51:26 AM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
2:51:26 AM: ​
2:51:26 AM:   Error location
2:51:26 AM:   In Build command from Netlify app:
2:51:26 AM:   npm run build
2:51:26 AM: ​
2:51:26 AM:   Resolved config
2:51:26 AM:   build:
2:51:26 AM:     command: npm run build
2:51:26 AM:     commandOrigin: ui
2:51:26 AM:     environment:
2:51:26 AM:       - NEXT_PUBLIC_REST_API_URL
2:51:26 AM:       - NEXT_PRIVATE_TARGET
2:51:26 AM:     publish: /opt/build/repo/.next
2:51:26 AM:     publishOrigin: ui
2:51:26 AM:   plugins:
2:51:26 AM:     - inputs: {}
2:51:26 AM:       origin: ui
2:51:26 AM:       package: '@netlify/plugin-nextjs'
2:51:27 AM: Caching artifacts
2:51:27 AM: Started saving node modules
2:51:27 AM: Finished saving node modules
2:51:27 AM: Started saving build plugins
2:51:27 AM: Finished saving build plugins
2:51:27 AM: Started saving pip cache
2:51:27 AM: Finished saving pip cache
2:51:27 AM: Started saving emacs cask dependencies
2:51:27 AM: Finished saving emacs cask dependencies
2:51:27 AM: Started saving maven dependencies
2:51:27 AM: Finished saving maven dependencies
2:51:27 AM: Started saving boot dependencies
2:51:27 AM: Finished saving boot dependencies
2:51:27 AM: Started saving rust rustup cache
2:51:27 AM: Finished saving rust rustup cache
2:51:27 AM: Started saving go dependencies
2:51:27 AM: Finished saving go dependencies
2:51:28 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
2:51:28 AM: Failing build: Failed to build site
2:51:28 AM: Finished processing build request in 1m30.85737364s

Thanks.

I disagree

Yeah, it’s currently down. But it was totally up the time I wrote it. The hosting provider of the API is still down atm. Lets wait and see…

Probably unrelated, but atm cloudflare is down and thats why the API is down https://www.cloudflarestatus.com. Let’s hope when it gets back up, my site builds normally. But at the time when I wrote this post, the API was still accessible at least from me (Europe).

Yeah, it’s still not working and my API is already up and running (and so did cloudflare): https://services.enfution.com/api/config

And this builds fine in Vercel. Is there any possibilities that maybe netlify is having problem in fetching this API, at least during build? Any help would be appreciated. Thx.

I don’t know anything about next js.

Hi, @dev.enfu.id. The ENOTFOUND error is a DNS lookup failure in most cases. To debug this I would add a DNS lookup command to the build command like so:

nslookup services.enfution.com ; npm run build

This will let you see what is being returned for that DNS lookup. If you add that to your build command it might tell you more about this error.

If you do so, please let us know and our support team can examine the build to see what it says.