help
help copied to clipboard
Random database disconnect getaddrinfo EAI_AGAIN
"Error: MongooseServerSelectionError: getaddrinfo EAI_AGAIN mongo"
I have a docker-compose file that creates a Nodejs app that depends on mongo that is on another docker. The compose runs properly but than at random I get the following error, why do I get this ?
Error:
{"level":"error","type":"none","message":"Error: MongooseServerSelectionError: getaddrinfo EAI_AGAIN mongo","service":"portal","timestamp":"21-03-21 01:54:24"}
The docker-compose file:
version: "3.2"
services:
portal:
container_name: portal
image: keybraker/portal:latest
build:
context: .
dockerfile: ./docker/Dockerfile
depends_on:
- mongo
volumes:
- type: bind
source: ../logs
target: /logs
mongo:
container_name: mongo
restart: always
image: mongo:4.4.3
ports:
- "29017:27017"
volumes:
- type: bind
source: ../mongo/data/db
target: /data/db
The docker file:
#latest might break unexpectedly
FROM node:14
# Create app directory
RUN mkdir -p /usr/src/portal
WORKDIR /usr/src/portal
# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./
COPY tsconfig*.json ./
# If you are building your code for production
# RUN npm ci --only=production else RUN npm install
RUN npm ci --only=production
RUN npm install typescript --save-dev
# Bundle app source
COPY . .
RUN npm run build
CMD [ "node", "build/index.js" ]
Environment
- Platform: X86 64bit (Amazon Web Services EC2)
- Docker Version: Docker version 19.03.13, build cd8016b6bc
- Node.js Version: 14
Expected Behavior
Should not randomly crash
Current Behavior
Randomly crashing I have read online that it is a nodejs DNS error, but can't find a solution
Possible Solution
There is something wrong with the DNS server of the instance. I am running the docker on aws instance EC2
Steps to Reproduce
Run a project that connects to another database and after one day it will randomly crash
Additional Information
Is anyone able to figure this out? I am getting the same error whenever I am using volumes for the mongo container. If I remove volumes from the mongo container, the mongoose gets connected to DB without any problem.
Is anyone able to figure this out? I am getting the same error whenever I am using
volumesfor themongocontainer. If I removevolumesfrom themongocontainer, the mongoose gets connected to DB without any problem.
Are you able to provide a complete reproducible example?
I've also had occasional EAI_AGAIN errors in production, and I'd like to do some debugging but I haven't found a way to reproduce the error.
It seems there has been no activity on this issue for a while, and it is being closed in 30 days. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.
It seems there has been no activity on this issue for a while, and it is being closed. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.