Application Failed To Respond 503 Error

My project all of a sudden went down and I'm met with a screen that says "Application Failed To Respond". I'm not really sure what is causing this issue since it happened in the last day or so. Any ideas on how to fix?
No description
Solution:
Turns out it was an issue with the front end. It was pointing to a recently expired domain, after removing it and redeploying the front end code everything started working again. Turned out to be a simple fix thankfully. Thanks for all your help
Jump to solution
27 Replies
Percy
Percy9mo ago
Project ID: 2caabd5e-e8d7-43a1-97ab-7d6d49a4d1f6
Len-goo-uh
Len-goo-uhOP9mo ago
2caabd5e-e8d7-43a1-97ab-7d6d49a4d1f6
Brody
Brody9mo ago
have you tried re-deploying it?
Len-goo-uh
Len-goo-uhOP9mo ago
re-deploying the server? I can try re-deploying didn't seem to help
Brody
Brody9mo ago
in that case, please read this docs page https://docs.railway.app/guides/fixing-common-errors
Len-goo-uh
Len-goo-uhOP9mo ago
Yeah, so I updated my server to follow the host and port example for node/express and merged it into may main branch and all I see in the deploy logs is: Start on port: 5705 Error: connect ECONNREFUSED 34.82.27.207:5876 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) { errno: -111, code: 'ECONNREFUSED', syscall: 'connect', address: '34.82.27.207', port: 5876 } Connect to mongoDB I'm still seeing the "Application failed to respond" page when going to my site. And the inspector still shows the 503 error. I tried re-deploying and it and no luck with that either.
Brody
Brody9mo ago
looks like your app is still trying to connect to the deleted legacy database, please switch your connection details over
Len-goo-uh
Len-goo-uhOP9mo ago
oh that's strange, I thought that had already been updated. I had it automatically done a few months ago when i got the warning about the databases. What connection details should I be looking at? It looks like the mongo details are all up-to-date. oh, wait. should i re-deploy the mongo database? I only re-deployed my server code. It's been 3 months since the mongo database had a deployment, maybe that is it?
Brody
Brody9mo ago
nope, you have your database connection details hardcoded somewhere, or they are simply still set to the old databases variables
Len-goo-uh
Len-goo-uhOP9mo ago
In my project I make sure not to hardcode anything, instead using ENV variables. I'm looking at my server and mongodb and I'm seeing all the new connection details in there. I made sure to note down my old database variables and there doesn't seem to be any of those referenced anywhere in the project to my knowledge. Because last week the project was up just fine, i found out today that it was down so something happened.
Brody
Brody9mo ago
I don't know what to tell you here, your code is still trying to connect to the old mongo database, the new database is for sure not running on port 5705 are you using reference variables?
Len-goo-uh
Len-goo-uhOP9mo ago
yeah, it looks like it. I just looked at my projects' shared variables in the settings and I'm seeing old data there. port 5705? Is that the port im supposed to running on? Right now I'm seeing my project on port 26152.
Brody
Brody9mo ago
your logs, port 5705 when connecting to mongo, that is incorrect if your app is running on port 26152 that is also incorrect, looks like you have a lot missconfigured
Len-goo-uh
Len-goo-uhOP9mo ago
I'm at a loss here. Like i said earlier, everything was migrated over just fine and my project has been up and running the past few months without issue. This issue im seeing is recent. I guess i'll have to just poke around more.
Brody
Brody9mo ago
are you using reference variables? you should not be using project level shared variables
Len-goo-uh
Len-goo-uhOP9mo ago
Yes, I'm using reference variables. It looks like none of my shared variables are being used except for NODE_ENV and NODE_OPTIONS
Brody
Brody9mo ago
show me how you have setup your reference variables please
Len-goo-uh
Len-goo-uhOP9mo ago
They're setup like this
No description
Brody
Brody9mo ago
okay but please show me how you have written your references
Len-goo-uh
Len-goo-uhOP9mo ago
wdym? Like this? Here is a portion of the ENV, this is how some things are declared, everything else is sensitive information. MONGOHOST=${{prod-MongoDB.MONGOHOST}} MONGOPASSWORD=${{prod-MongoDB.MONGOPASSWORD}} MONGOPORT=${{prod-MongoDB.MONGOPORT}} MONGOUSER=${{prod-MongoDB.MONGOUSER}} MONGO_URL=${{prod-MongoDB.MONGO_URL}} NODE_ENV=${{shared.NODE_ENV}} NODE_OPTIONS=${{shared.NODE_OPTIONS}} PATH_LOG_ERROR_FILE=request.log PATH_LOG_REQUEST_FILE=request.log REDISHOST=${{prod-Redis.REDISHOST}} REDISPASSWORD=${{prod-Redis.REDISPASSWORD}} REDISPORT=${{prod-Redis.REDISPORT}} REDISUSER=${{prod-Redis.REDISUSER}} REDIS_HOST_URI=${{prod-Redis.REDIS_URL}} REDIS_URL=${{prod-Redis.REDIS_URL}}
Brody
Brody9mo ago
yeah that stuff looks good, let's see how you are using them in code
Len-goo-uh
Len-goo-uhOP9mo ago
Sure, it looks like most of the variables i showed you aren't used in the project itself. Here is my config.ts file showing some of the key ENV vars declared. I can also show my server.ts file if you want too. export const PORT = process.env.PORT ?? 3000; export const NODE_ENV = process.env.NODE_ENV as string; export const DOMAIN_SERVER = ${NODE_ENV === 'production' ? ${process.env.DOMAIN_SERVER as string} : 'http://localhost:3000'}; export const DOMAIN_CLIENT = ${NODE_ENV === 'production' ? ${process.env.DOMAIN_CLIENT as string} : 'http://localhost:3001'}; export const MONGODB_URI = process.env.MONGODB_URI as string; export const REDIS_HOST_URI = process.env.REDIS_HOST_URI as string; export const EXPESS_SESSION_SECRET = process.env.EXPESS_SESSION_SECRET as string; export const JWT_SECRET = process.env.EXPESS_SESSION_SECRET as string; export const OAUTH_CALLBACK_URL = ${NODE_ENV === 'production' ? ${process.env.DOMAIN_SERVER as string} : 'http://localhost:3000'}; export const PATH_LOG_ERROR_FILE = process.env.PATH_LOG_ERROR_FILE ?? 'request.log'; export const PATH_LOG_REQUEST_FILE = process.env.PATH_LOG_REQUEST_FILE ?? 'error.log'; export const FB_PIXEL_ID = process.env.FB_PIXEL_ID as string; export const FB_CONVERSIONS_API_ACCESS_TOKEN = process.env.FB_CONVERSIONS_API_ACCESS_TOKEN as string; export const GRAPH_API_VERSION = process.env.GRAPH_API_VERSION as string;
Brody
Brody9mo ago
show me both the mongo and redis client code please
Len-goo-uh
Len-goo-uhOP9mo ago
const app = express();
const RedisStore = connectRedis(session);
const redisClient = createClient({
url: REDIS_HOST_URI,
legacyMode: true, // https://github.com/tj/connect-redis/issues/336
});

redisClient
.connect()
.then(() => console.log('Connect to Redis'))
.catch((error) => console.log(error));

mongoose
.connect(MONGODB_URI)
.then(() => console.log('Connect to mongoDB'))
.catch((error) => console.log(error));

app.use(helmet());
app.use(cors({ origin: '*' }));
app.use(express.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cookieParser());

app.use(
session({
name: 'sessionId',
store: new RedisStore({ client: redisClient }),
secret: EXPESS_SESSION_SECRET,
resave: false,
saveUninitialized: false,
cookie: {
maxAge: 3600000 * 24 * 7, // 7 days
httpOnly: true,
},
}),
);

app.use(passport.initialize());
app.use(passport.session());

passport.use(googleStrategy);
passport.use(githubStrategy);
passport.use(facebookStrategy);

app.use(requestLogger);
app.use(rootRouter);
app.use(errorLogger);

app.use(errors());
app.use(errorHandler);

// @ts-expect-error
app.listen(PORT, '0.0.0.0', () => console.log(`Start on port: ${PORT}`));
const app = express();
const RedisStore = connectRedis(session);
const redisClient = createClient({
url: REDIS_HOST_URI,
legacyMode: true, // https://github.com/tj/connect-redis/issues/336
});

redisClient
.connect()
.then(() => console.log('Connect to Redis'))
.catch((error) => console.log(error));

mongoose
.connect(MONGODB_URI)
.then(() => console.log('Connect to mongoDB'))
.catch((error) => console.log(error));

app.use(helmet());
app.use(cors({ origin: '*' }));
app.use(express.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cookieParser());

app.use(
session({
name: 'sessionId',
store: new RedisStore({ client: redisClient }),
secret: EXPESS_SESSION_SECRET,
resave: false,
saveUninitialized: false,
cookie: {
maxAge: 3600000 * 24 * 7, // 7 days
httpOnly: true,
},
}),
);

app.use(passport.initialize());
app.use(passport.session());

passport.use(googleStrategy);
passport.use(githubStrategy);
passport.use(facebookStrategy);

app.use(requestLogger);
app.use(rootRouter);
app.use(errorLogger);

app.use(errors());
app.use(errorHandler);

// @ts-expect-error
app.listen(PORT, '0.0.0.0', () => console.log(`Start on port: ${PORT}`));
nvm, fixed it!
Brody
Brody9mo ago
what was the issue?
Solution
Len-goo-uh
Len-goo-uh9mo ago
Turns out it was an issue with the front end. It was pointing to a recently expired domain, after removing it and redeploying the front end code everything started working again. Turned out to be a simple fix thankfully. Thanks for all your help
Brody
Brody9mo ago
awesome, glad it was a simple fix
Want results from more Discord servers?
Add your server