Can't access MYSQL privately from Nodejs app

AnonymousFREE

a year ago

I am getting error.

at async Sequelize.authenticate (/app/node_modules/sequelize/lib/sequelize.js:457:5) {

parent: Error: getaddrinfo ENOTFOUND mysql.railway.internal

at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:118:26) {

errno: -3008,

code: 'ENOTFOUND',

syscall: 'getaddrinfo',

hostname: 'mysql.railway.internal',

fatal: true

},

original: Error: getaddrinfo ENOTFOUND mysql.railway.internal

at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:118:26) {

errno: -3008,

code: 'ENOTFOUND',

syscall: 'getaddrinfo',

hostname: 'mysql.railway.internal',

fatal: true

}

}

0 Replies

AnonymousFREE

a year ago

This is my dockerfile

# use a smaller base image
FROM node:lts-alpine AS base

# set working directory
WORKDIR /app

# copy package files and install dependencies
COPY package*.json ./
RUN npm ci --omit=dev --quiet

# copy source code and build app
FROM base AS build
COPY . .
RUN npm i typescript
RUN npm i tsc-alias
RUN npm run build
RUN npm prune --production

# create final image
FROM base AS final
COPY --from=build ./app/config ./config
COPY --from=build ./app/dist ./dist
COPY --from=build ./app/node_modules ./node_modules

# set environment variables
EXPOSE 3000

CMD sh -c "sleep 3 && npm start"

AnonymousFREE

a year ago

1202557948421865500


a year ago

for an alpine based docker image, please see this docs section


touchyspideyTRIAL

a year ago

I didn't find a rule about texting in someone else's thread, I hope it's ok for me to add to this, if not I apologize

Project ID: 4cc0d132-ab38-44ae-8c5c-8bfc804592eb

I had the same error as Piyush about reaching mysql on private networking from nodejs (expressjs)

I applied the alpine workaround, meaning that I've set that env variable on nodejs

now I'm getting a different error, a connection timeout

I've read this in the docs: "Note that using this workaround will cause the 100ms DNS initialization delay to impact both public and private networking."
could it be it?

1217157087377883100
1217157087768084700


a year ago

nixpacks or dockerfile?


touchyspideyTRIAL

a year ago

nixpacks


a year ago

then the alpine variable is not applicable, please add a 3 second sleep to your start script


touchyspideyTRIAL

a year ago

awesome, it lives! thank you mate

I'm guessing it was the same problem = private networking dns wasn't up fast enough?
and the fact that I got a different error after setting the alpine variable was a coincidence?


a year ago

the docs say 100ms but in reality it's more like 2 seconds