Static React App - "Application Failed to Respond" After Successful Deploy

devsubairariyil
HOBBY

2 months ago

Hi Railway Team,

I’ve deployed a static website built with React to Railway. The build and deployment complete successfully, but when I access the generated URL, I get the following error:

"Application failed to respond"

Here's some context:

  • The app is a static React site built using yarn build.

  • I'm using serve -s build -l $PORT as the start command.

  • Deployment logs indicate the build succeeded, and the server should be running.

  • However, the app doesn't respond and eventually times out.

Could you please help me identify what’s going wrong or guide me on how to properly serve a static React site via Railway/Nixpacks?

Thank you!
Subair

$10 Bounty

33 Replies

Railway
BOT

2 months ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


2 months ago

Hey, did you check the target port as mentioned in the documentation regarding this?


devsubairariyil
HOBBY

2 months ago

This resolved my app loading issue, now I am getting raw html pages. The build and deployment steps complete successfully on Railway, but when I visit the app URL, I just see a white page. The page source reveals that the index.html file is served without the %PUBLIC_URL% placeholders being replaced — it's serving the raw template from /public instead of the output in /build.


2 months ago

Hey, if you are using Railpack, I recommend checking out the docs at https://railpack.com/languages/node#static-sites, if configured correctly (you will have to remove your start command), it will be served using Caddy. You may also want to take a look at this template by Brody, which deploys a static React with vite using Railpack https://github.com/brody192/vite-react-template.


devsubairariyil
HOBBY

2 months ago

Thanks for the quick reply. This project doesn't have any start/build command.


devsubairariyil

Thanks for the quick reply. This project doesn't have any start/build command.

2 months ago

Hey, is the static React already built and therefore only need to be served? If this is the case, then please take a look at https://railpack.com/languages/staticfile/.


devsubairariyil
HOBBY

2 months ago

I added the env variable to set the root to build folder, but didn't help.
This my workflow, once the build completed, I push the build folder to railway.
- name: Install dependencies

run: yarn install --frozen-lockfile

- name: Build static site

run: yarn build

- name: Install Railway CLI

run: npm install -g @railway/cli

- name: Deploy static site to Railway

run: cd build && railway up --service=${{ env.SVC_ID }} --ci

As it the react project, it is supposed from from the build folder. Build folder has an index.html and the static folder.
I am unable to identify what's going wrong.


2 months ago

Hey, can you please provide the build logs of your service from Railway?


devsubairariyil
HOBBY

2 months ago

Here is the build logs


devsubairariyil
HOBBY

2 months ago

Jul 19 20:16:47

exporting to docker image format

Jul 19 20:16:47

exporting to image

Jul 19 20:16:49

[auth] sharing credentials for production-us-east4-eqdc4a.railway-registry.com

Jul 19 20:16:49

[auth] sharing credentials for production-us-east4-eqdc4a.railway-registry.com 0 ms

Jul 19 20:16:50

importing to docker

Jul 19 20:16:56

importing to docker  5 secs

Jul 19 20:17:07

=== Successfully Built! ===

Jul 19 20:17:07

Run:

Jul 19 20:17:07

docker run -it production-us-east4-eqdc4a.railway-registry.com/cb383532-fee5-45e7-b765-077d6dfa1973:a0cb778d-eb52-4572-a623-4b2a702fa88c

Jul 19 20:17:07

Build time: 45.46 seconds


2 months ago

Hey, the message you sent only has the last bits of your build logs. Try clicking on the download icon and copy as plain text, for example:

Attachments


devsubairariyil
HOBBY

2 months ago

Pls find the attached log


devsubairariyil
HOBBY

2 months ago

It seems attachment not working on this thread


devsubairariyil

It seems attachment not working on this thread

2 months ago

Hey, can you try pasting the logs or show the error when trying to attach a file to your message?


devsubairariyil
HOBBY

2 months ago

when I tried attaching the log file, it didn't show any error, but the file wasn't got attached.


2 months ago

Interesting, can you try pasting the entire logs as a message?


devsubairariyil
HOBBY

2 months ago


uxuz

Interesting, can you try pasting the entire logs as a message?

devsubairariyil
HOBBY

2 months ago

Not sure why, I am unable to paste logs, even little bigger portion of the logs are also not allowed


devsubairariyil

https://drive.google.com/file/d/1-ZO2gPYQSuJcuBwrMNtJq_bBIMgIRv64/view?usp=sharingI moved the log to my google drive

2 months ago

Hey, thank you for the logs, can you try changing the builder to Railpack (this can be done within your service's settings)?


devsubairariyil
HOBBY

2 months ago

I changed to Railpack. after redeployment, I am getting 404 in http logs.

Attachments


devsubairariyil

I changed to Railpack. after redeployment, I am getting 404 in http logs.

2 months ago

Hey, can you show the build logs of this particular deployment? Can you also show your project's structure, as we may need to overwrite the static file root?


devsubairariyil
HOBBY

2 months ago

I removed the env variable. now deployment failed.

Attachments


devsubairariyil
HOBBY

2 months ago

This is how my build folder looks like

Attachments


2 months ago

Hey, can you add your static file root directory back (I suppose it was RAILPACK_STATIC_FILE_ROOT=build) and show the build logs?


devsubairariyil
HOBBY

2 months ago

ok . let me try that


devsubairariyil
HOBBY

2 months ago


devsubairariyil

https://drive.google.com/file/d/1sLcWZwkSo2LoHywjyJZyFf3K0t418tqE/view?usp=sharingdeployment completed, but page is not accessible

2 months ago

Hmmm, I am a bit confused as for why the index.html isn't served. What if you remove the environment/service variable and set the service's root directory to /build?

Attachments


devsubairariyil
HOBBY

2 months ago

then deployment fails with this message - Could not find root directory: /build


devsubairariyil
HOBBY

2 months ago

A truly appreciate the help and support but I don't know where would this end up. I have 4 services in my project, and I am supposed to deliver the production environment ready by Aug first week. My client is ready to go for a pro subscription when we go for production deployment, I did not reach that level of confidence yet.
Interesting part is, this service was up and running, as the cost reached the threshold, all service were taken down. As it reset after the billini cycle, redeployment did not go we ll. I ended up in rewriting the pipeline, revisited the dependencies and somehow reached this point. And still struggling to get the index.html served.


devsubairariyil
HOBBY

2 months ago

I have another service which is a front end website like this but written in next js, and it works just fine.


2 months ago

Hey, I understand your frustration, can you perhaps provide a minimal reproducible example of your static React app, so that I can take a look at it and debug it from my end?


Status changed to Open brody 2 months ago


Status changed to Open brody 2 months ago


devsubairariyil
HOBBY

2 months ago

Hi,
I tried with a modified docker - copying the build folder to html folder in nginx image. Deployment was completed successful, but I was getting 502. Now I configured for auto-deployment, triggering from a push to develop branch, still same result.


devsubairariyil

Hi,I tried with a modified docker - copying the build folder to html folder in nginx image. Deployment was completed successful, but I was getting 502. Now I configured for auto-deployment, triggering from a push to develop branch, still same result.

2 months ago

Hey, as stated in the message prior, would it be possible for you to provide a minimal reproducible example of your application, so that I can take a closer look?