Courseiva

DVA-C02 Troubleshooting and Optimization Practice Question

A company uses AWS CodePipeline with CodeBuild to deploy a Node.js application. The build fails intermittently with 'npm ERR! network' errors. What is the most likely cause and solution?

⚠ Common exam trap

Candidates often assume 'npm ERR! network' is always a local cache or token issue, overlooking the VPC networking configuration. Another trap is forgetting that CodeBuild in a VPC requires a NAT gateway for internet access, and misconfiguring routing in even one of the selected subnets will cause intermittent build failures.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

The build environment lacks outbound internet access; configure a NAT gateway or use a VPC endpoint for npm.

The 'npm ERR! network' error indicates that npm cannot reach the registry to download packages. If AWS CodeBuild is configured to run inside a VPC, it requires outbound internet access to reach the public npm registry. If CodeBuild is configured with multiple subnets and some of them lack a route to a NAT gateway, the builds will fail intermittently depending on which subnet the build container is provisioned in. To resolve this, ensure all configured subnets have a route to a NAT gateway, or host your packages in AWS CodeArtifact and use a VPC endpoint to access them privately.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    A unit test is failing; fix the test code.

    Why it's wrong here

    An ECONNRESET error indicates a network connection was forcibly closed by the peer, which is fundamentally different from a unit test failure. Unit tests typically fail due to incorrect code logic or unmet assertions, resulting in specific assertion errors (e.g., 'expected X but got Y') rather than low-level network communication issues. Therefore, fixing test code would not resolve a network reset problem.

  • ✗

    The npm cache is corrupted; clear the cache in CodeBuild.

    Why it's wrong here

    AWS CodeBuild environments are ephemeral, meaning each build starts with a fresh, clean environment. There is no persistent npm cache that could become corrupted and carry over between builds. An ECONNRESET error specifically points to a problem with the network connection itself, not an issue with local cached data, making cache clearing irrelevant.

  • ✓

    The build environment lacks outbound internet access; configure a NAT gateway or use a VPC endpoint for npm.

    Why this is correct

    An ECONNRESET error signifies that the remote server unexpectedly closed the connection, often due to the client's inability to establish or maintain network connectivity. For CodeBuild projects running in a private VPC subnet, outbound internet access is crucial for npm install to fetch packages from public registries. Configuring a NAT Gateway in a public subnet or utilizing a VPC endpoint for specific services like S3 (if npm packages are stored there) provides the necessary outbound path, resolving such network-related build failures.

  • ✗

    The npm token has expired; regenerate the token.

    Why it's wrong here

    An expired or invalid npm token, typically used for authenticating with private package registries, would result in an HTTP 401 Unauthorized error, indicating an authentication failure. An ECONNRESET error, however, is a lower-level TCP error that means the connection was forcibly closed by the peer, pointing to a fundamental network connectivity issue rather than an authentication problem. Regenerating a token would not address a network reset.

Visual reference

Inside (Private) PC-A 10.0.0.1 PC-B 10.0.0.2 NAT Router Outside (Public) 203.0.113.1 Inside Global Server PAT: many private IPs share one public IP via unique port numbers

About these practice questions

Courseiva writes every DVA-C02 question from scratch — 1,135 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This DVA-C02 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DVA-C02 exam.