Railway error on path

I'm getting this one railway Path: / Retry window: 5m0s Attempt #1 failed with service unavailable. Continuing to retry for 4m59s Attempt #2 failed with service unavailable. Continuing to retry for 4m58s Attempt #3 failed with service unavailable. Continuing to retry for 4m56s Attempt #4 failed with service unavailable. Continuing to retry for 4m52s Attempt #5 failed with service unavailable. Continuing to retry for 4m44s Attempt #6 failed with service unavailable. Continuing to retry for 4m28s Attempt #7 failed with service unavailable. Continuing to retry for 3m58s Attempt #8 failed with service unavailable. Continuing to retry for 3m28s Attempt #9 failed with service unavailable. Continuing to retry for 2m58s Attempt #10 failed with service unavailable. Continuing to retry for 2m28s Attempt #11 failed with service unavailable. Continuing to retry for 1m58s Attempt #12 failed with service unavailable. Continuing to retry for 1m28s Attempt #13 failed with service unavailable. Continuing to retry for 58s Attempt #14 failed with service unavailable. Continuing to retry for 28s 1/1 replicas never became healthy! Healthcheck failed! is this whats causing it?
137 Replies
Percy
Percyā€¢2y ago
Project ID: N/A
hondacivicchan
hondacivicchanOPā€¢2y ago
n/a
Brody
Brodyā€¢2y ago
is this a create react app?
hondacivicchan
hondacivicchanOPā€¢2y ago
its using Vite
Brody
Brodyā€¢2y ago
based could i see your repo?
hondacivicchan
hondacivicchanOPā€¢2y ago
sure
hondacivicchan
hondacivicchanOPā€¢2y ago
GitHub
GitHub - HondaChan14/Bit-Source
Contribute to HondaChan14/Bit-Source development by creating an account on GitHub.
Brody
Brodyā€¢2y ago
you are missing a start command, use the start command from this template https://github.com/brody192/vite-react-template you will also need to install serve with npm i serve
hondacivicchan
hondacivicchanOPā€¢2y ago
šŸ˜® ohhh ima look up what serve does
Brody
Brodyā€¢2y ago
read that templates readme and also lookup what serve does too
hondacivicchan
hondacivicchanOPā€¢2y ago
ohhh wow yeah ima check it out now is this part of the script needed>? -s -n -L -p $PORT
Brody
Brodyā€¢2y ago
um yes
hondacivicchan
hondacivicchanOPā€¢2y ago
okay its having a hard time with Error: Unknown --listen endpoint scheme (protocol): undefined
Brody
Brodyā€¢2y ago
is that an error from railway?
hondacivicchan
hondacivicchanOPā€¢2y ago
sorry i was wrong umm i still get the same Path: / Retry window: 5m0s Attempt #1 failed with service unavailable. Continuing to retry for 4m59s Attempt #2 failed with service unavailable. Continuing to retry for 4m58s Attempt #3 failed with service unavailable. Continuing to retry for 4m56s Okay now the front client side works now im having problem with the server side haha XD
Brody
Brodyā€¢2y ago
whats wrong with the server
hondacivicchan
hondacivicchanOPā€¢2y ago
im getting this Acess to fetch at 'http://localhost:8000/' from origin 'https://bit-source-production-3798.up.railway.app' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header has a value 'http://localhost:3000' that is not equal to the supplied origin. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Brody
Brodyā€¢2y ago
its normal for this to happen a few times while your app starts up
hondacivicchan
hondacivicchanOPā€¢2y ago
I'd thught this had fixed it const corsOptions = { origin: process.env.Origin, }; app.use(cors(corsOptions)); app.use(express.json()); app.use((req, res, next) => { res.setHeader('Content-Type', 'application/json'); next(); }); but i guess not
Brody
Brodyā€¢2y ago
you cant request something over http from a site accessed over https you need to send fetch requets to your backend domain (https://bit-source-production-3798.up.railway.app/), not localhost
hondacivicchan
hondacivicchanOPā€¢2y ago
ohh so i would change this. So i guess best practice is to make it into an env variable?
Brody
Brodyā€¢2y ago
yeah an environment variable would be a good idea
hondacivicchan
hondacivicchanOPā€¢2y ago
ima try it out! hopefully it works but i wanna say you are a master wizard ā¤ļø
Brody
Brodyā€¢2y ago
no problem šŸ™‚ wow, are you ever in luck a RAILWAY_{serviceName}_STATIC_URL variable was just added, you no longer need to add your own hard coded variable https://docs.railway.app/develop/variables#railway-provided-variables
hondacivicchan
hondacivicchanOPā€¢2y ago
HYPERS let me check it out ty!
Brody
Brodyā€¢2y ago
you can also do this, say you had a service named energized soda you could access the domain for it with the variable RAILWAY_SERVICE_ENERGIZED_SODA_URL
hondacivicchan
hondacivicchanOPā€¢2y ago
what does it mean by service name?
Brody
Brodyā€¢2y ago
the name of the server service
Brody
Brodyā€¢2y ago
hondacivicchan
hondacivicchanOPā€¢2y ago
peepoShy ohh lol
Brody
Brodyā€¢2y ago
https://github.com/HondaChan14/Bit-Source/blob/585f9bc72da941cb4bd09156b7f5af333ec865c7/client/src/pages/Home/LandingPage.jsx#LL10C9-L10C9 it should be
const response = await fetch(import.meta.env.RAILWAY_BIT_SOURCE_URL);
const response = await fetch(import.meta.env.RAILWAY_BIT_SOURCE_URL);
hondacivicchan
hondacivicchanOPā€¢2y ago
ohh its not import.meta.env.RAILWAY_BIT_SOURCE_STATIC_URL ?
Brody
Brodyā€¢2y ago
i forgot this was vite for a sec, my bad
hondacivicchan
hondacivicchanOPā€¢2y ago
its okay! šŸ™‚
Brody
Brodyā€¢2y ago
let me know it that works
hondacivicchan
hondacivicchanOPā€¢2y ago
No šŸ˜¦ dex-6dcfe425.js:67 SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON is coming from LandingPage (
Brody
Brodyā€¢2y ago
status code?
hondacivicchan
hondacivicchanOPā€¢2y ago
304
hondacivicchan
hondacivicchanOPā€¢2y ago
Brody
Brodyā€¢2y ago
are you sure? show me the address its requesting to please
hondacivicchan
hondacivicchanOPā€¢2y ago
Brody
Brodyā€¢2y ago
and what's your backend service's domain? and I also realized that you'd need to prefix the value from that variable with https://
hondacivicchan
hondacivicchanOPā€¢2y ago
my backend is running on port http://localhost:8000
Brody
Brodyā€¢2y ago
you would need to be running your backend on railway so that when you are running the frontend on railway, the frontend can access the backend
hondacivicchan
hondacivicchanOPā€¢2y ago
ohh so I would have to make a new project setup?
Brody
Brodyā€¢2y ago
no just add another service to your current project add an empty service, set the correct root directory, then add the repo
hondacivicchan
hondacivicchanOPā€¢2y ago
omg i cant be this dumb <:legend_stare:1082262128028831864>
Brody
Brodyā€¢2y ago
haha no worries mate
hondacivicchan
hondacivicchanOPā€¢2y ago
okay i made a new domain for the backend
Brody
Brodyā€¢2y ago
screenshot of entire project please?
hondacivicchan
hondacivicchanOPā€¢2y ago
hondacivicchan
hondacivicchanOPā€¢2y ago
Brody
Brodyā€¢2y ago
what one is the backend and what one is the front-end
hondacivicchan
hondacivicchanOPā€¢2y ago
Top is front end bottom is back end
Brody
Brodyā€¢2y ago
then why does the backend deployment show a commit that was made to the frontend code
hondacivicchan
hondacivicchanOPā€¢2y ago
hondacivicchan
hondacivicchanOPā€¢2y ago
hmmm
Brody
Brodyā€¢2y ago
okay prob just a display bug i see your backend uses mongodb you will need to add a mongodb plugin to your project, then setup the variable references https://docs.railway.app/develop/variables#reference-variables then show me a screenshot of your backends service variables
hondacivicchan
hondacivicchanOPā€¢2y ago
im geting this in the deploy log for the backend npm WARN config production Use --omit=dev instead.
[email protected] start node server.js
Connected to database Listening on port 8000 šŸ˜®
Brody
Brodyā€¢2y ago
lots to do eh?
hondacivicchan
hondacivicchanOPā€¢2y ago
it seems like it is connect to mongodb just the fetch on the front end is not getting a repsonse
Brody
Brodyā€¢2y ago
i dont see mongodb here?
hondacivicchan
hondacivicchanOPā€¢2y ago
okay i think ima continue this tmrrw as its pretty late for me but ima try to figure it out and if anything ill come back šŸ˜„ tysm! i learned alot!
Brody
Brodyā€¢2y ago
todo tomorrow
hondacivicchan
hondacivicchanOPā€¢2y ago
tys, you are amazing ā¤ļø
Brody
Brodyā€¢2y ago
thank you
hondacivicchan
hondacivicchanOPā€¢2y ago
Sorry im abit behind but i was finally able to add the mongodb plugin
Brody
Brodyā€¢2y ago
its been a while, catch me up
hondacivicchan
hondacivicchanOPā€¢2y ago
yeah haha sorry but I was able to change my mongodb string to the MONGO_URL railway plugin provides.
hondacivicchan
hondacivicchanOPā€¢2y ago
hondacivicchan
hondacivicchanOPā€¢2y ago
Only issue im having now is that its having a hard time fetching to my backend
Brody
Brodyā€¢2y ago
is there errors you can show me?
hondacivicchan
hondacivicchanOPā€¢2y ago
npm WARN config production Use --omit=dev instead.
[email protected] start node server.js
MongooseError: The uri parameter to openUri() must be a string, got "undefined". Make sure the first parameter to mongoose.connect() or mongoose.createConnection() is a string. at _createMongoClient (/app/node_modules/mongoose/lib/connection.js:768:11) at NativeConnection.openUri (/app/node_modules/mongoose/lib/connection.js:705:29) at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:406:15) at Object.<anonymous> (/app/server.js:24:6) at Module._compile (node:internal/modules/cjs/loader:1155:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10) at Module.load (node:internal/modules/cjs/loader:1033:32) at Function.Module._load (node:internal/modules/cjs/loader:868:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:22:47 npm WARN config production Use --omit=dev instead.
[email protected] start node server.js
MongooseError: The uri parameter to openUri() must be a string, got "undefined". Make sure the first parameter to mongoose.connect() or mongoose.createConnection() is a string. at _createMongoClient (/app/node_modules/mongoose/lib/connection.js:768:11) at NativeConnection.openUri (/app/node_modules/mongoose/lib/connection.js:705:29) at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:406:15) at Object.<anonymous> (/app/server.js:24:6) at Module._compile (node:internal/modules/cjs/loader:1155:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10) at Module.load (node:internal/modules/cjs/loader:1033:32) at Function.Module._load (node:internal/modules/cjs/loader:868:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:22:47
Brody
Brodyā€¢2y ago
show me your backends service variables please
hondacivicchan
hondacivicchanOPā€¢2y ago
hondacivicchan
hondacivicchanOPā€¢2y ago
I just used this
Brody
Brodyā€¢2y ago
please show me the service variables
hondacivicchan
hondacivicchanOPā€¢2y ago
hondacivicchan
hondacivicchanOPā€¢2y ago
ohhh im dumb
hondacivicchan
hondacivicchanOPā€¢2y ago
Brody
Brodyā€¢2y ago
there we go
hondacivicchan
hondacivicchanOPā€¢2y ago
okay so thats fixed. now this is the issue const response = await fetch(import.meta.env.RAILWAY_BIT_SOURCE_URL);
Brody
Brodyā€¢2y ago
what is RAILWAY_BIT_SOURCE_URL you do not have a service named bit source
hondacivicchan
hondacivicchanOPā€¢2y ago
youre right i changed soCuteImLooking am i so dumb? lol
Brody
Brodyā€¢2y ago
lol
hondacivicchan
hondacivicchanOPā€¢2y ago
hondacivicchan
hondacivicchanOPā€¢2y ago
okay i changed it
Brody
Brodyā€¢2y ago
it doesnt need to be caps you can have it "Bit Source" and railway will normalize it to BIT_SOURCE Bit-Source -> BIT_SOURCE bit source -> BIT_SOURCE bit's source's -> BIT_S_SOURCE_S you get the idea
hondacivicchan
hondacivicchanOPā€¢2y ago
ohh okay
Brody
Brodyā€¢2y ago
you would need to rebuild your app that is accessing that environment variable
hondacivicchan
hondacivicchanOPā€¢2y ago
ohh the redeploy?
Brody
Brodyā€¢2y ago
yes redeploy same diff
hondacivicchan
hondacivicchanOPā€¢2y ago
whats the difference with restart and redeploy?
Brody
Brodyā€¢2y ago
restart will only restart your app itself, this will not refresh the variables redeploy will rebuild your app again, and this will make the new variables available
hondacivicchan
hondacivicchanOPā€¢2y ago
šŸ˜® oohh hmm okay im still getting dex-6dcfe425.js:67 SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON i
Brody
Brodyā€¢2y ago
the bit source service is your frontend, correct?
hondacivicchan
hondacivicchanOPā€¢2y ago
yes!
import React, { useEffect, useState } from 'react';
import IssueBoard from '../../Components/IssueBoard/IssueBoard';

const LandingPage = () => {
const [issues, setIssues] = useState([]);

useEffect(() => {
const fetchIssues = async () => {
try {
const response = await fetch(import.meta.env.RAILWAY_BIT_SOURCE_URL);
const data = await response.json();
setIssues(data);
} catch (error) {
console.error(`${error} is coming from LandingPage`);
}
};
fetchIssues();
}, []);

return (
<div className="bg-red-400 min-h-screen">
<IssueBoard issues={issues} />
</div>
);
};

export default LandingPage;
import React, { useEffect, useState } from 'react';
import IssueBoard from '../../Components/IssueBoard/IssueBoard';

const LandingPage = () => {
const [issues, setIssues] = useState([]);

useEffect(() => {
const fetchIssues = async () => {
try {
const response = await fetch(import.meta.env.RAILWAY_BIT_SOURCE_URL);
const data = await response.json();
setIssues(data);
} catch (error) {
console.error(`${error} is coming from LandingPage`);
}
};
fetchIssues();
}, []);

return (
<div className="bg-red-400 min-h-screen">
<IssueBoard issues={issues} />
</div>
);
};

export default LandingPage;
Brody
Brodyā€¢2y ago
what service are you using the RAILWAY_BIT_SOURCE_URL variable in?
hondacivicchan
hondacivicchanOPā€¢2y ago
the front end
Brody
Brodyā€¢2y ago
why are you using the frontends own domain in the frontend service? also, you should not be manually setting that variable, please delete it i think you might be confused tell me what you are trying to do
hondacivicchan
hondacivicchanOPā€¢2y ago
I need the fetch inside the frontend to call the backend since the backend is grabbing data from the github api
Brody
Brodyā€¢2y ago
you want to fetch the backend, from the frontend?
hondacivicchan
hondacivicchanOPā€¢2y ago
Brody
Brodyā€¢2y ago
delete that please, you should not be setting that variable yourself
hondacivicchan
hondacivicchanOPā€¢2y ago
okay! will do
Brody
Brodyā€¢2y ago
correct?
hondacivicchan
hondacivicchanOPā€¢2y ago
yes!
Brody
Brodyā€¢2y ago
you can use the variable RAILWAY_SERVICE_BACK_END_URL you will need to prefix the resulting value with https:// you do not need to create this yourself
hondacivicchan
hondacivicchanOPā€¢2y ago
const response = await fetch(import.meta.env.RAILWAY_SERVICE_BACK_END_URL);
Brody
Brodyā€¢2y ago
^
hondacivicchan
hondacivicchanOPā€¢2y ago
im not following šŸ˜¦
Brody
Brodyā€¢2y ago
do you know what the word prefix means?
const response = await fetch(`https://${import.meta.env.RAILWAY_SERVICE_BACK_END_URL}`);
const response = await fetch(`https://${import.meta.env.RAILWAY_SERVICE_BACK_END_URL}`);
hondacivicchan
hondacivicchanOPā€¢2y ago
ohhh im sorry i thought of it a diofferent way and then just add typical-cow-production.up.railway.app to the frontend variables
Brody
Brodyā€¢2y ago
NO!! you do not need to create this yourself
hondacivicchan
hondacivicchanOPā€¢2y ago
ahhh
Brody
Brodyā€¢2y ago
look https://utilities.up.railway.app/env-vars i have not set any service variables at all, they are all made by railway automatically
hondacivicchan
hondacivicchanOPā€¢2y ago
ohhh okay wow i def have alot to learn
Brody
Brodyā€¢2y ago
perslaps
hondacivicchan
hondacivicchanOPā€¢2y ago
its different now dex-676250a3.js:67 GET https://undefined/ net::ERR_NAME_NOT_RESOLVED (anony
hondacivicchan
hondacivicchanOPā€¢2y ago
I do see this in the deply log **
Brody
Brodyā€¢2y ago
hmmm yes i know the problem hold on while i think of a solution
hondacivicchan
hondacivicchanOPā€¢2y ago
Thanks brody for everything ohh i tried this const response = await fetch(https://${import.meta.env.VITE_RAILWAY_SERVICE_BACK_END_URL}); but now getting Acess to fetch at 'https://typical-cow-production.up.railway.app/' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Brody
Brodyā€¢2y ago
you set VITE_RAILWAY_SERVICE_BACK_END_URL yourself didnt you
hondacivicchan
hondacivicchanOPā€¢2y ago
i did it on my local to try it out
Brody
Brodyā€¢2y ago
locally you would need to connect to your locally running backend
hondacivicchan
hondacivicchanOPā€¢2y ago
i see. okay for now i wanna put a pin on this since i gotta get dinner ready but omg tysm! i feel like im finally getting close
Brody
Brodyā€¢2y ago
sounds good, im still thinking on the undefined variable
hondacivicchan
hondacivicchanOPā€¢2y ago
okay tysm! ā¤ļø
Brody
Brodyā€¢2y ago
it is not the most elegant solution ever, but change your build script to this VITE_BACK_END_URL=$RAILWAY_SERVICE_BACK_END_URL vite build then you can use this
const response = await fetch(`https://${import.meta.env.VITE_BACK_END_URL}`);
const response = await fetch(`https://${import.meta.env.VITE_BACK_END_URL}`);
hondacivicchan
hondacivicchanOPā€¢2y ago
like this? "VITE_BACK_END_URL=$RAILWAY_SERVICE_BACK_END_URL": "vite build",
Brody
Brodyā€¢2y ago
lol no "build": "VITE_BACK_END_URL=$RAILWAY_SERVICE_BACK_END_URL vite build"
hondacivicchan
hondacivicchanOPā€¢2y ago
okay thanks haha OMG IT FULLY WORKS!
hondacivicchan
hondacivicchanOPā€¢2y ago
hondacivicchan
hondacivicchanOPā€¢2y ago
soCuteImLooking ā™„ļø
Brody
Brodyā€¢2y ago
yippe
hondacivicchan
hondacivicchanOPā€¢2y ago
tysm for all your help you are truely a god HYPERS
Brody
Brodyā€¢2y ago
no problem, always happy to help
Want results from more Discord servers?
Add your server