Hi,
A couple of days ago, my server suddenly stopped being able to call external urls from within my node app (using NestJS). Everything has been working fine, there were no deployments at the time, it just stopped.
My app is running inside a docker container, and was using Alpine as its base, but having looked around on here, I saw a suggestion that was to switch it to Slim, so I did that and redeployed, no good.
I then took the nuclear option as someone had tried here, so I deleted my app and recreated it. That has since been done, a deployment has been made, but still no good.
What’s strange is I sometimes seem to get maybe one or two requests to my app that work, and then it just stops. The external urls are not timing out themselves or giving errors, if I run my app locally the calls work just fine.
If I make a request to an endpoint on my app that doesn’t require an external url, then it gets returned, so I know the app is running ok.
I’m unsure what could have caused this, but I could do with some help in getting this back up and running and I’m open to all suggestions.
In case it’s useful, this is my docker file
FROM node:18-slim AS BUILD_IMAGE
# https://medium.com/trendyol-tech/how-we-reduce-node-docker-image-size-in-3-steps-ff2762b51d5a
WORKDIR /usr/src/app
COPY . .
RUN npm config set cache /tmp --global
# The rimraf node_modules is run before npm ci as otherwise NPM throws a WARN about it
RUN npm install rimraf -g && \
npm run bootstrap-server:ci && \
npm run build-common && \
npm run build-server && \
rimraf ['node_modules', 'apiclient/node_modules', 'cinema-api/node_modules']
# Install dependencies for production
RUN npm ci --omit=dev && \
cd apiclient && \
npm ci --omit=dev && \
npm link && \
cd ../cinema-api && \
npm ci --omit=dev && \
npm link @cinemaplanner/api-client
FROM node:18-slim AS RUNTIME
LABEL fly_launch_runtime="nodejs"
WORKDIR /usr/src/app
COPY --from=BUILD_IMAGE /usr/src/app/node_modules ./node_modules
COPY --from=BUILD_IMAGE /usr/src/app/apiclient ./apiclient
COPY --from=BUILD_IMAGE /usr/src/app/cinema-api ./cinema-api
ENV NODE_ENV=production
EXPOSE 3000
EXPOSE 8080
WORKDIR /usr/src/app/cinema-api
CMD ["npm", "run", "start:prod"]
From my logs in the fly monitor, this is the error I end up with
2023-12-21T11:13:52.924 app[e286033c927738] lhr [info] Error: connect ETIMEDOUT 2606:4700::6811:6081:443
2023-12-21T11:13:52.924 app[e286033c927738] lhr [info] at AxiosError.from (/usr/src/app/cinema-api/node_modules/axios/dist/node/axios.cjs:837:14)
2023-12-21T11:13:52.924 app[e286033c927738] lhr [info] at RedirectableRequest.handleRequestError (/usr/src/app/cinema-api/node_modules/axios/dist/node/axios.cjs:3029:25)
2023-12-21T11:13:52.924 app[e286033c927738] lhr [info] at RedirectableRequest.emit (node:events:517:28)
2023-12-21T11:13:52.924 app[e286033c927738] lhr [info] at RedirectableRequest.emit (node:domain:489:12)
2023-12-21T11:13:52.924 app[e286033c927738] lhr [info] at eventHandlers.<computed> (/usr/src/app/cinema-api/node_modules/follow-redirects/index.js:14:24)
2023-12-21T11:13:52.924 app[e286033c927738] lhr [info] at ClientRequest.emit (node:events:529:35)
2023-12-21T11:13:52.924 app[e286033c927738] lhr [info] at ClientRequest.emit (node:domain:489:12)
2023-12-21T11:13:52.924 app[e286033c927738] lhr [info] at TLSSocket.socketErrorListener (node:_http_client:501:9)
2023-12-21T11:13:52.924 app[e286033c927738] lhr [info] at TLSSocket.emit (node:events:517:28)
2023-12-21T11:13:52.924 app[e286033c927738] lhr [info] at TLSSocket.emit (node:domain:489:12)