1

I've deployed a docker image to an Azure Linux App Service which contains a node app. The app is failing to start properly because it can't connect to a Mongo version of Cosmo DB.

error: MongoError: failed to connect to server [***.documents.azure.com:10255] on first connect [MongoError: getaddrinfo EAI_AGAIN ***.documents.azure.com:10255]

I'm using mongoose and the following to connect:

mongoose.connect(process.env.MONGODB_URL, { useMongoClient: true });

Running the app in a container locally on my machine works. Is there something I'm missing? Some DNS/Firewall setting?

Dockerfile:

FROM mhart/alpine-node:latest

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
COPY package.json package-lock.json ./

RUN npm install --production

# Bundle app source
COPY . .

EXPOSE 4000

CMD [ "node", "main.js" ]

2 Answers 2

1

Yes, open outbound ports 10250-10256 and 443 to work with Cosmos DB. Also, make sure your mongodb connection string has ?ssl=true parameter set.

Sign up to request clarification or add additional context in comments.

2 Comments

Is that a setting in the Dockerfile or something in the App Service in Azure?
That is a client-side setting - those ports are obviously open on Azure side and they don't change.
0

The problem is to do with the image I was using:

FROM mhart/alpine-node:latest

There seems to be a problem with DNS when using this image when deploying it to Azure.

Switched to use

FROM node:latest

and everything is now working.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.