R
Railway

✋|help

Can't connect to Redis

Ttansan.eth8/22/2023
This is the error I am getting. What I have checked so far
* Made sure I used the env variables provided by Railway
* Exposed the REDISPORT in my dockerfile

Error: connect ECONNREFUSED 127.0.0.1:6379

at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1595:16) {

errno: -111,

code: 'ECONNREFUSED',

syscall: 'connect',

address: '127.0.0.1',

port: 6379

}
Ttansan.eth8/22/2023
049b9d61-9cd8-4102-aad9-1350a56e2b7e
Ttansan.eth8/22/2023
I saw this message, but unclear what the actionable item is here for my Dockerfile
Bbrody1928/22/2023
send the dockerfile please
Ttansan.eth8/22/2023
FROM node:20-alpine

WORKDIR /app

ARG REDISPORT=6379

RUN apk add --update --no-cache \
    make \
    g++ \
    jpeg-dev \
    cairo-dev \
    giflib-dev \
    pango-dev \
    libtool \
    autoconf \
    automake \
    git

COPY package.json ./
COPY package-lock.json ./

RUN npm ci

COPY . .

# redis
EXPOSE ${REDISPORT}/tcp

CMD ["npm", "run", "start"]

I believe that is correct?
Bbrody1928/22/2023
okay so help me understand why you have redisport stuff?
Ttansan.eth8/22/2023
I thought Docker was not exposing the port correctly and the one provided to me by Railway is different from the default, so I am accepting it via the env var and exposing it
Bbrody1928/22/2023
you're connecting to redis, you don't need to expose anything
remove the ARG and EXPOSE stuff please
next, show me a screenshot of your service variables please
Ttansan.eth8/22/2023
Ttansan.eth8/22/2023
Removed the ARG and EXPOSE and still unable to connect
Bbrody1928/22/2023
I know, we will work through this, have patience please
Ttansan.eth8/22/2023
Oh I was just updating you since you were instructing me to remove the arg and expose. I wasn't trying to rush you. My apologies if it came off that way.
Bbrody1928/22/2023
go ahead and add the rest of the redis reference variables now
Ttansan.eth8/22/2023
Okay, I just finished doing that
Bbrody1928/22/2023
screenshot please
Ttansan.eth8/22/2023
Ttansan.eth8/22/2023
Do I have to keep those env vars even if I am only referencing REDIS_URL in my application code?
Bbrody1928/22/2023
no, but I don't know what you reference in code so it was a safe bet to ask you to use them all
now show me the redis connector code please
Ttansan.eth8/22/2023
Bbrody1928/22/2023
what package are you using for redis
Bbrody1928/22/2023
what's the ! for
Ttansan.eth8/22/2023
TypeScript thing to tell it the var will always be defined
Bbrody1928/22/2023
fancy
Ttansan.eth8/22/2023
yeah pretty useful
Bbrody1928/22/2023
okay well it looks fine then
but your error comes from trying to connect to the default redis host and port, so your code isn't actually trying to connect to the url you have specified
Ttansan.eth8/22/2023
Yeah, I suspect it might be a docker issue
Bbrody1928/22/2023
no it's not, this is a code issue
share your repo and I'll have a look to see if anything stands out for me?
Ttansan.eth8/22/2023
For what it's worth, I have it working locally with a redis url
I can share the file, but let me double check one thing
Bbrody1928/22/2023
unfortunately "it works locally" does not rule out this being a code issue
Solution
Ttansan.eth8/22/2023
Ttansan.eth8/22/2023
Okay, I'll sort it out. I'll try explicit env vars of port, user, pass, etc...
Bbrody1928/22/2023
see, it's a good thing I had you add them all!
Ttansan.eth8/22/2023
LOL
:kekW:
Bbrody1928/22/2023
foresight
and see, it's not a docker issue
Ttansan.eth8/22/2023
Not a docker issue, but definitely relevant
Bbrody1928/22/2023
I don't see how it is, but lol
Ttansan.eth8/22/2023
y u being like this
naw but i think you're right though. I always think its docker related when i see errors related to 127.0.0.1
Bbrody1928/22/2023
it's just a loopback address, really nothing to do with docker
Ttansan.eth8/22/2023
@Brody guess what. It's docker relevant.
Wait going to share a repo with you. I think you are more knowledgable here and might be able to explain this better than I can.
@Brody Is it possible to rotate my REDIS username and password later? I am thinking to just hardcode it in the private repo for the brevity
Bbrody1928/22/2023
chill with the pings please #🛂|readme #5
but yes you can rotate your redis credentials, and no you should not hardcode the credentials even for brevity
Ttansan.eth8/22/2023
My apologies. I appreciate you letting me know.
Bbrody1928/22/2023
just share your repo lol
again, it's not a docker issue, if this was, there would be a hell of a lot more people in here saying they can't connect to redis, since regardless of using a dockerfile or nixpacks, docker is used in the end
Ttansan.eth8/22/2023
Ah nevermind. I was testing the repo then realized I made mistake in my earlier testing. I can't figure out the issue. Will try again in the morning!

However, it's clear its a library issue, so I don't want to use anymore of your time! Thank you for the help, as always!
Bbrody1928/22/2023
no problem

Looking for more? Join the community!

Recommended Posts
Hello everyone, i'm trying to make a python websocket using websockets library also flaskso basically i have this -> ```py async def main(): url = os.environ.get('RAILWAY_URL', 'localExtension of Payment Due Date for SubscriptionIs there a way I can request for a brief extension of a few days for my upcoming payment?Hello Everyone! I am facing some problem related to deploying my nodejs application.I have deployed my nodejs application using github, but do not know how can I connect phpmyadmin so RedeployHey there, is there away to start a redploy using the Railway APIKafka Connectioncould anyone help me setup kafka cluster? I've went through the deployment process but getting a conHosting a monorepo with a Vite/Svelte Front and and a Fiber BackendI am trying to host my monorepo application within railway however I am facing some issues when tryiUnexpected timeouts and slow downsHey guys! I'm writing this post since we've been experimenting some slow downs and timeouts during tconfigure variable in VM ARGUMENTSI would like to know how do I create a variable "VM Arguments" in the railway environment? currentluhmm i think i filled the entire disk somehowservice id: 66b587c8-3c50-4dd0-8dfa-394ade04a0eci want to deploy a wordpres, is it possible?project id fb928ae2-62f0-4f8f-be68-9f7902efbebdBilled per usage plan with carryoverHey guys, I'm currently on a usage based plan but my app is only projected to use $1.70/month. Will How to use the Kafka project?I'm relatively new to Kafka and I want to publish and consume events to the Kafka running in a kafkaCannot login to Railway.app this morningHere's what I'm doing to login: I go to railway.app, and select Login enter my email address and preRelative path issueI am trying to read some Json files and parse them with one of my services. Locally it works fine. Can't run Railway CLI down command with project tokenhey , it is possible to run the railway down command with railway project token without logging in. Ruby on Rails Deployment with database and redisi had a few questions about linking my database and redis server within railway app ... I tried but Lost all my 20$ credits out of no whereSo i just got an email saying my projects needs 3$ in credits, but suddenly when i check? my whole 2any reason why my usage suddenly jumps to 4GB when there are no tasks running?The app had no requests for for the entire day but the usage jumped, any reason why this could happei want to dowload my post gre db locallyhow can i dowload my post-gre db locallyCloudflare custom domain not workingI just upgraded the api for Cloudflare, but the custom domain is no longer working