Error is a socket timeout issue during the npm install process, possibly related to network connectivity or proxy settings in a Dockerized application

I am encountering an issue while working on my Dockerized application and would greatly appreciate your assistance in resolving it.

Issue Type: Socket Error during npm install

OS Version/Build: (Docker container)

OS: Windows 10 Home
Device : Intel i5 10300H 8GB RAM 1TB HDD

Steps to Reproduce:

  1. Clone the project
  2. Navigate to the project directory.
  3. Run docker-compose -f docker-compose-development.yml up --build to start the application.

Error Log:

ERROR [app development 2/9] RUN npm install                                                                                                       90.9s
 > [app development 2/9] RUN npm install:
32.20 npm WARN deprecated request@2.88.2: request has been deprecated, see
35.71 npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
56.94 npm WARN deprecated har-validator@5.1.3: this library is no longer supported
57.55 npm WARN deprecated flatten@1.0.2: flatten is deprecated in favor of utility frameworks such as lodash.
68.38 npm WARN deprecated bson@1.0.9: Fixed a critical issue with BSON serialization documented in CVE-2019-2391, see for more details
82.80 npm notice
82.80 npm notice New major version of npm available! 8.5.0 -> 10.1.0
82.80 npm notice Changelog: <>
82.80 npm notice Run `npm install -g npm@10.1.0` to update!
82.80 npm notice
82.80 npm ERR! code ERR_SOCKET_TIMEOUT
82.80 npm ERR! network Socket timeout
82.80 npm ERR! network This is a problem related to network connectivity.
82.80 npm ERR! network In most cases you are behind a proxy or have bad network settings.
82.80 npm ERR! network
82.80 npm ERR! network If you are behind a proxy, please make sure that the
82.80 npm ERR! network 'proxy' config is set properly.  See: 'npm help config'
82.82 npm ERR! A complete log of this run can be found in:
82.82 npm ERR!     /root/.npm/_logs/2023-10-01T18_14_14_246Z-debug-0.log
failed to solve: process "/bin/sh -c npm install" did not complete successfully: exit code: 1

Docker Compose File (docker-compose-development.yml):

(version: '3.4'
    image: mongo:4.4
      - dbdata:/data/db
      context: ./
      dockerfile: Dockerfile
      target: development
      - MONGO_URL=mongodb://mongo:27017/p5js-web-editor
      - .:/usr/src/app
      - /usr/src/app/node_modules
      - '8000:8000'
      - '8002:8002'
      - mongo


FROM node:16.14.2 as base
ENV APP_HOME=/usr/src/app \
RUN mkdir -p $APP_HOME

FROM base as development
ENV NODE_ENV development
COPY package.json package-lock.json ./
RUN npm install
RUN npm rebuild node-sass
COPY .babelrc index.js nodemon.json ./
COPY ./webpack ./webpack
COPY client ./client
COPY server ./server
COPY translations/locales ./translations/locales
COPY public ./public
CMD ["npm", "start"]

FROM development as build
ENV NODE_ENV production
RUN npm run build

FROM base as production
ENV NODE_ENV=production
COPY package.json package-lock.json index.js ./
RUN npm install --production
RUN npm rebuild node-sass
COPY --from=build $APP_HOME/dist ./dist
CMD ["npm", "run", "start:prod"]

Issue Description:
I am currently working on a Dockerized Node.js application, and I’m facing a socket error during the npm install process. The error message suggests that it’s related to network connectivity and may be due to a proxy or network configuration issue.

Error Details:

  • The npm install command runs into a socket timeout error.
  • The error message suggests that it may be related to network connectivity and proxy settings.
  • The application is containerized using Docker, and it seems to be affecting the npm installation process.

Request for Help:
I’m seeking guidance on how to resolve this socket timeout error. If you have encountered a similar issue or have expertise in Docker and npm, your insights would be greatly appreciated. Please let me know if you need any additional information or logs to assist in diagnosing and resolving this problem.

Thank you in advance for your help!