Application Failed to Respond
andres-vr
FREEOP

3 months 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
FREEOP

3 months ago

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


fra
HOBBY

3 months ago

any logs in the frontend?


andres-vr
FREEOP

3 months ago

Deploy logs

1408815102328701200


andres-vr
FREEOP

3 months ago

http logs

1408815177960263700


uxuz
MODERATOR

3 months 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
FREEOP

3 months 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


uxuz
MODERATOR

3 months ago

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


andres-vr
FREEOP

3 months ago

1408880603461587000
1408880603775893500
1408880604090732500


andres-vr
FREEOP

3 months ago

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


uxuz
MODERATOR

3 months ago

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


andres-vr
FREEOP

3 months 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
FREEOP

3 months ago

Is there any place I should change it to 5000?


uxuz
MODERATOR

3 months 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
FREEOP

3 months ago

on all domains?


andres-vr
FREEOP

3 months ago

it worked, tysm


uxuz
MODERATOR

3 months ago

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


andres-vr
FREEOP

3 months ago

Sure


uxuz
MODERATOR

3 months ago

!s


Status changed to Solved uxuz 4 months ago


Loading...