title: Getting build error occurred when running npm run build
body: <p>The app fetches data from local Javascript file via an api. Here is below the error and code.</p>
  <blockquote>
  <p>$ npm run build</p>
  <p>next-crash-course@0.1.0 build<br />
  next build &amp;&amp; next export</p>
  <p>Browserslist: caniuse-lite is outdated. Please run:
  npx browserslist@latest --update-db
  info  - Creating an optimized production build
  info  - Compiled successfully</p>
  <p><strong>Build error occurred
  FetchError: request to http://localhost:3000/api/articles failed, reason: connect ECONNREFUSED 127.0.0.1:3000</strong>
  at ClientRequest. (C:\WebTest_NextJS(Brad Traversy)\pr1\node_modules\node-fetch\lib\index.js:1461:11)
  at ClientRequest.emit (node:events:369:20)
  at Socket.socketErrorListener (node:_http_client:462:9)
  at Socket.emit (node:events:369:20)
  at emitErrorNT (node:internal/streams/destroy:188:8)
  at emitErrorCloseNT (node:internal/streams/destroy:153:3)
  at processTicksAndRejections (node:internal/process/task_queues:81:21) {
  type: 'system',
  errno: 'ECONNREFUSED',
  code: 'ECONNREFUSED'
  }
  info  - Collecting page data .npm ERR! code 1
  npm ERR! path C:\Test_NextJS\pr1
  npm ERR! command failed
  npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c next build &amp;&amp; next export</p>
  <p>npm ERR! A complete log of this run can be found in:
  npm ERR!     C:\Users\MH1\AppData\Local\npm-cache_logs\2021-05-21T02_51_47_465Z-debug.log</p>
  </blockquote>
  <p>NOTE: in the dev mode everything work fine.
  Code link: <a href="https://github.com/bradtraversy/next-crash-course" rel="nofollow noreferrer">https://github.com/bradtraversy/next-crash-course</a></p>