Application Failed to Respond

andres-vr
FREE

a month ago

My railway application fails to respond on my domain.

I tried to

  • let railway auto detect ports

  • change the backend host to 0.0.0.0 and port to 8080 (auto detected by Caddy)

  • check my DNS, which correctly links my www subdomain to railway

Backend: Uses docker, auto detected port 8080, deploy succeeded, empty HTTP logs
Frontend: Uses railpack, port 5000, deploy succeeded, HTTP logs in screenshot

Backend server.js:
import express from 'express';
import mongoose from 'mongoose';
import dotenv from 'dotenv';
import cors from 'cors';

import hotelRoutes from './routes/hotelRoutes.js';
import accountRoutes from './routes/accountRoutes.js';

dotenv.config();

const app = express();
const port = process.env.PORT || 5000;

app.use(
cors({
origin: ['http://localhost:5173', 'https://www.nightbucks.com', 'https://frontend-production-16d8.up.railway.app', 'https://frontend-staging-9695.up.railway.app'],
})
);

app.use(express.json());

app.use('/api/hotels', hotelRoutes);
app.use('/api/account', accountRoutes);

// Start server with DB connection
(async () => {
try {
app.listen(port, "0.0.0.0", () => {
console.log(✅ App listening on port: ${port});
});
} catch (err) {
console.error('❌ Startup error:', err);
process.exit(1);
}
})();

Frontend API Calls (which worked 3 days ago):
const domain = import.meta.env.PROD
? "https://backend-production-fe67.up.railway.app"
: "http://localhost:5000";

const url = `${domain}/api/account/add/search`;
Solved$10 Bounty

1 Replies

andres-vr
FREE

a month ago

Project ID: d9a138f0-83d2-4162-8ed9-905775d3273a
Feel free to @ me when you reply


fra
HOBBYTop 5% Contributor

a month ago

any logs in the frontend?


andres-vr
FREE

a month ago

Deploy logs

1408815102328701200


andres-vr
FREE

a month ago

http logs

1408815177960263700


a month ago

Hey @Andiesgames, instead of hardcoding the URL, it may be beneficial to read them as environment (service) variables, which can be achieved using reference variables such as [https://${{backend.RAILWAY_PUBLIC_DOMAIN](https://${{backend.RAILWAY_PUBLIC_DOMAIN)}} (this assumes that the frontend is calling the backend on the client and not on the server such as during SSR).

Now to the "Application Failed to Respond" problem, since the problem is with the frontend please provide more context, such as the last time it has worked, the changes made before breaking it, a screenshot of your public networking section and other related information to help us pinpoint the cause.


andres-vr
FREE

a month ago

Good point, my plan is to use api.nightbucks.com as railway ENV variable, but it wasn't setup before today.

As for code i've changed on the frontend: some pinia stores, some vue components, api requests to the backend, localstorage instead of refs, etc
All changes worked fine in dev, also no build or deploy errors on railway

It certainly worked 3 days ago, but I haven't changed any config since then


a month ago

Would you be able to provide the deploy logs and a screenshot of your public networking section of your frontend service?


andres-vr
FREE

a month ago

1408880603461587000
1408880603775893500
1408880604090732500


andres-vr
FREE

a month ago

nightbucks.com will redirect to www.nightbucks.com via cloudflare, and www is set as CNAME via cloudflare DNS


a month ago

Can you show the part that configures your frontend to listen on port 5000?


andres-vr
FREE

a month ago

I haven't configured it anywhere, I just assumed it would be the same as the main railway domain, and it used to work 4 days ago like this


andres-vr
FREE

a month ago

Is there any place I should change it to 5000?


a month ago

I believe that you should be able to overwrite it with a service variable if you are using the default Caddyfile that Railpack uses. However, before we try that, try changing the the public networking's port to 8080, which I believe is the default.


andres-vr
FREE

a month ago

on all domains?


andres-vr
FREE

a month ago

it worked, tysm


a month ago

You are welcome, I'll mark this thread as solved if you don't have any further questions.


andres-vr
FREE

a month ago

Sure


a month ago

!s


Status changed to Solved uxuz about 1 month ago