Application Failed To Respond 503 Error

guestman360
TRIAL

a year ago

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?

0 Replies

guestman360
TRIAL

a year ago

2caabd5e-e8d7-43a1-97ab-7d6d49a4d1f6


a year ago

have you tried re-deploying it?


guestman360
TRIAL

a year ago

re-deploying the server? I can try


guestman360
TRIAL

a year ago

re-deploying didn't seem to help


a year ago

in that case, please read this docs page


guestman360
TRIAL

a year 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 {
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.


a year ago

looks like your app is still trying to connect to the deleted legacy database, please switch your connection details over


guestman360
TRIAL

a year 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.


guestman360
TRIAL

a year ago

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?


a year ago

nope, you have your database connection details hardcoded somewhere, or they are simply still set to the old databases variables


guestman360
TRIAL

a year 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.


guestman360
TRIAL

a year ago

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.


a year 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


a year ago

are you using reference variables?


guestman360
TRIAL

a year ago

yeah, it looks like it. I just looked at my projects' shared variables in the settings and I'm seeing old data there.


guestman360
TRIAL

a year ago

port 5705? Is that the port im supposed to running on? Right now I'm seeing my project on port 26152.


a year ago

your logs, port 5705 when connecting to mongo, that is incorrect


a year ago

if your app is running on port 26152 that is also incorrect, looks like you have a lot missconfigured


guestman360
TRIAL

a year 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.


a year ago

are you using reference variables? you should not be using project level shared variables


guestman360
TRIAL

a year ago

Yes, I'm using reference variables. It looks like none of my shared variables are being used except for NODEENV and NODEOPTIONS


a year ago

show me how you have setup your reference variables please


guestman360
TRIAL

a year ago

They're setup like this

1217547196476690700


a year ago

okay but please show me how you have written your references


guestman360
TRIAL

a year 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}}
MONGOURL=${{prod-MongoDB.MONGOURL}}
NODEENV=${{shared.NODEENV}}
NODEOPTIONS=${{shared.NODEOPTIONS}}
PATHLOGERRORFILE=request.log PATHLOGREQUESTFILE=request.log
REDISHOST=${{prod-Redis.REDISHOST}}
REDISPASSWORD=${{prod-Redis.REDISPASSWORD}}
REDISPORT=${{prod-Redis.REDISPORT}}
REDISUSER=${{prod-Redis.REDISUSER}}
REDISHOSTURI=${{prod-Redis.REDISURL}} REDISURL=${{prod-Redis.REDIS_URL}}


a year ago

yeah that stuff looks good, let's see how you are using them in code


guestman360
TRIAL

a year 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 NODEENV = process.env.NODEENV as string;

export const DOMAINSERVER = ${NODE_ENV === 'production' ?${process.env.DOMAINSERVER as string}: '[http://localhost:3000](http://localhost:3000)'};
export const DOMAINCLIENT = ${NODE_ENV === 'production' ?${process.env.DOMAINCLIENT as string}: '[http://localhost:3001](http://localhost:3001)'};

export const MONGODBURI = process.env.MONGODBURI as string;

export const REDISHOSTURI = process.env.REDISHOSTURI as string;

export const EXPESSSESSIONSECRET = process.env.EXPESSSESSIONSECRET as string;

export const JWTSECRET = process.env.EXPESSSESSION_SECRET as string;

export const OAUTHCALLBACKURL = ${NODE_ENV === 'production' ?${process.env.DOMAIN_SERVER as string}: '[http://localhost:3000](http://localhost:3000)'};

export const PATHLOGERRORFILE = process.env.PATHLOGERRORFILE ?? 'request.log';
export const PATHLOGREQUESTFILE = process.env.PATHLOGREQUESTFILE ?? 'error.log';

export const FBPIXELID = process.env.FBPIXELID as string;

export const FBCONVERSIONSAPIACCESSTOKEN = process.env.FBCONVERSIONSAPIACCESSTOKEN as string;

export const GRAPHAPIVERSION = process.env.GRAPHAPIVERSION as string;


a year ago

show me both the mongo and redis client code please


guestman360
TRIAL

a year 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}`));

Anonymous
TRIAL

a year ago

Account failed to finish deploy


Anonymous
TRIAL

a year ago

What's the problem


guestman360
TRIAL

a year ago

nvm, fixed it!


a year ago

what was the issue?


guestman360
TRIAL

a year 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


a year ago

awesome, glad it was a simple fix


Application Failed To Respond 503 Error - Railway Help Station