ENOTFOUND redis.railway.internal
digitalcraft
PROOP

2 years ago

First time using railway.
I'm on team plan which says it supports private networking.
I have a simple nodejs application and a redis service.
I've shared the redis variables as per the guide.

project id is: 32ae1873-09b1-4c70-ae4b-ca9b93e854da

is something broken or am i missing something?

import Redis from "ioredis";
const redis = new Redis(process.env.REDIS_URL);

REDISURL is shared from the service as ${{Redis.REDISPRIVATE_URL}}

67 Replies

2 years ago

please have a look at this docs section for ioredis


digitalcraft
PROOP

2 years ago

i've updated to const redis = new Redis(process.env.REDIS_URL + "?family=0");

i still have the same error.


digitalcraft
PROOP

2 years ago

does it matter that i started this project as hobby, where im told private networking doesn't work. and then imported things to team?


2 years ago

nope, doesnt matter.
have you added a 3 second sleep to your start script?


digitalcraft
PROOP

2 years ago

lol no.


2 years ago

please try that


digitalcraft
PROOP

2 years ago

ok


digitalcraft
PROOP

2 years ago

i got dragged away for a meeting. this is still no go. even with the 3second delay.


2 years ago

nixpacks or dockerfile?


digitalcraft
PROOP

2 years ago

i just pushing up a project. looking at the build logs, its using nixpack, which is ubuntu based.


digitalcraft
PROOP

2 years ago

so i have a working nodejs application (locally). im just pushing it up to test railway. i usually use heroku.


2 years ago

to be clear, you get ENOTFOUND redis.railway.internal when deployed to railway right?


digitalcraft
PROOP

2 years ago

yeah


2 years ago

can you show me how you have implemented the 3 second sleep?


digitalcraft
PROOP

2 years ago

const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
await delay(3000);


digitalcraft
PROOP

2 years ago

just block. do this at the top before any dns lookups would happen


2 years ago

please add the sleep to your start script instead


digitalcraft
PROOP

2 years ago

oh so make my start script… sleep 3000; node index.js


digitalcraft
PROOP

2 years ago

3 maybe


2 years ago

that would sleep for 50 minutes, sleep 3 is what you want


digitalcraft
PROOP

2 years ago

ok its actually different now.

/app/nodemodules/ioredis/built/Redis.js:332 command.reject(new Error(utils1.CONNECTIONCLOSEDERROR_MSG));


2 years ago

what version of ioredis are you using?


digitalcraft
PROOP

2 years ago

so do i need username and password for internal connection?


digitalcraft
PROOP

2 years ago

i currently am…


2 years ago

yes of course


digitalcraft
PROOP

2 years ago

"ioredis": "^5.3.2",


2 years ago

thats latest, so thats good


2 years ago

what is REDIS_URL set to?


digitalcraft
PROOP

2 years ago

redis://default:464lPFFidM4ll2K6olIBNHAgJgiG21ap@redis.railway.internal:6379


2 years ago

it should be set to ${{Redis.REDIS_PRIVATE_URL}}


digitalcraft
PROOP

2 years ago

const redis = new Redis(process.env.REDIS_URL + "?family=0");


digitalcraft
PROOP

2 years ago

yes it is…


digitalcraft
PROOP

2 years ago

${{Redis.REDISPRIVATEURL}}


digitalcraft
PROOP

2 years ago

i expanded it


2 years ago

okay lets see your client code please


digitalcraft
PROOP

2 years ago

sure… here is the stacktrace.


2 years ago

please send the redis client code


digitalcraft
PROOP

2 years ago

well its actually not the ioredis this time… it might be a similar issue with bull. not sure if your familiar with this.


digitalcraft
PROOP

2 years ago

im just reading the docs here. it says everything in the second param is passed right to the iosredis constructor. https://github.com/OptimalBits/bull/blob/develop/REFERENCE.md#queue


digitalcraft
PROOP

2 years ago

so im also instantiating a queue.

const fetchHTMLQueue = new Queue(
"fetchHTML",
process.env.REDIS_URL + "?family=0"
);


digitalcraft
PROOP

2 years ago

and now its breaking on .getJobs().


digitalcraft
PROOP

2 years ago

`await redis.set("block:https://www.centrecom.com/test/product", "404");

let alreadyQueued = (await fetchHTMLQueue.getJobs(["active", "waiting"])).map(
(job) => job.data.url
);`


2 years ago

okay I'll try to get a minimal reproducible example working with that library


digitalcraft
PROOP

2 years ago

does it break for you also?


2 years ago

I haven't started, currently eating dinner


digitalcraft
PROOP

2 years ago

what country? im from Aus


2 years ago

Canada


digitalcraft
PROOP

2 years ago

Nice!


digitalcraft
PROOP

2 years ago

looks like there is a bug in bull, i think i got it sorted


2 years ago

what was it?


digitalcraft
PROOP

2 years ago

so when you initilise a queue with bull, and pass in a redis connection string. it uses a url parser to pull it apart and then passes this to ioredis constructor


digitalcraft
PROOP

2 years ago

ioredis constructor expects family to be 0 no '0'


digitalcraft
PROOP

2 years ago

TypeError [ERRINVALIDARG_VALUE]: The property 'options.family' must be one of: 0, 4, 6. Received '0'


2 years ago

ah it wants it to be a number


digitalcraft
PROOP

2 years ago

anyhow… still not out of the woods. more issues. with redis. but ill have more of a play till i bother you again. but is definilty not the "point and click" i was expecting


2 years ago

yeah very odd that ioredis defaults to ipv4


digitalcraft
PROOP

2 years ago

ok so i have all this working now… thanks fro your help.


digitalcraft
PROOP

2 years ago

do i need to stay on the team for private networking to work? or will my nodejs still be able to connect to redis on hobby?


2 years ago

private networking is not limited to pro, but depending on your workload, you may need to stay on pro anyway


digitalcraft
PROOP

2 years ago

when i do railway up, at what point can i kill that and it will still deploy?


2 years ago

after its done uploading, you may be interested in the --detach flag

~> railway up --help
Upload and deploy project from the current directory

Usage: railway up [OPTIONS] [PATH]

Arguments:
  [PATH]

Options:
  -d, --detach                     Don't attach to the log stream
  -s, --service           Service to deploy to (defaults to linked service)
  -e, --environment   Environment to deploy to (defaults to linked environment)
      --json                       Output in JSON format
  -h, --help                       Print help
  -V, --version                    Print version

digitalcraft
PROOP

2 years ago

yeah ok ill do -d


digitalcraft
PROOP

2 years ago

is there any ETA's for sydney/melbourne regions?


2 years ago

nope, but you upvote this forum post and with enough upvotes it will show the team that there is need for that region


digitalcraft
PROOP

2 years ago

done


digitalcraft
PROOP

2 years ago

i'd say that needs a bit more circulation


2 years ago

you are welcome to circulate it in a non intrusive way


Loading...