5 months ago
My repo https://github.com/vikchaudhary/resumegen has:
frontend/ -- react app
backend/ -- python
On my local machine, I do the following to start my app:
python3 backend/app.py
npm start
In Railway, I first get these build failures:
> install │ python -m venv --copies /opt/venv && . /opt/venv/bin/activate ║
Feb 04 20:09:49
>║ │ && pip install -r requirements.txt ║
I would really appreciate any help from the Railway gurus out here! Thank you!
Vik
11 Replies
5 months ago
Hello,
I think you are looking for this tutorial?
https://docs.railway.com/tutorials/deploying-a-monorepo
Status changed to Awaiting User Response railway • 5 months ago
5 months ago
Thanks, brody, I appreciate that help with structuring my Railway to match my monorepo directory structure. I created two services, a frontend (react) and a backend (python). The build is succeeding for both services.
Now I get a runtime error with the backend service because Railway is looking for the python component reactpy
. I do have them listed in my ./requirements.txt
(it's in the root folder, not in the backend/ folder, though). Any ideas?File "/app/main.py", line 1, in <module>
from reactpy import component, html
ModuleNotFoundError: No module named 'reactpy'
Status changed to Awaiting Railway Response railway • 5 months ago
5 months ago
I'm getting the hang of this. I moved my requirements.txt into the backend folder, and added reactpy
. Then it failed with another library missing, fastapi
, so added that as well. Now, when I start my backend service by clicking on the url, I got this:Application failed to respond
This error appears to be caused by the application.
If this is your project, check out your deploy logs to see what went wrong. Refer to our docs on Fixing Common Errors for help, or reach out over our Help Station.
If you are a visitor, please contact the application owner or try again later.
Request ID:
YS0ON8ZXRbe4el95Psnj8Q_3987874068
Looking at the http logs, I see 502 errors which indicates a port error. Hmmm.... ok I'll go look at the help files.
5 months ago
You would want to be starting your fastapi server with uvicorn -
https://docs.railway.com/reference/errors/no-start-command-could-be-found#fastapi
And similarly, you would want to be running your frontend with a production grade web server too, for that I recommend caddy -
https://github.com/brody192/create-react-app-starter
Just copy the nixpacks.toml and Caddyfile from this repo into your frontend folder.
Status changed to Awaiting User Response railway • 5 months ago
5 months ago
Hi Brody, I have made my project public: https://railway.com/project/cb4e200f-3c07-423e-aa77-22de9bb106dd
(1) For the frontend/ I copied the nixpacks.toml and Caddyfile into the frontend/ directory
I run the application by going to the URL in settings: http://frontend-production-1cb0.up.railway.app/
Still get the "Application failed to respond error", as above
(2) My backend application is written in python, so shouldn't my start command just be: "python app.py"?
Note: the backend app uses Flask, but changing my start command to "gunicorn app.py:app" didn't work either
Still get the "Application failed to respond error", as above
Status changed to Awaiting Railway Response railway • 5 months ago
5 months ago
Here are the logs:
frontend Deploy log:Starting Container
using config from file
adapted config to JSON
Caddyfile input is not formatted; run 'caddy fmt --overwrite' to fix inconsistencies
admin endpoint disabled
automatic HTTPS is completely disabled for server
started background certificate maintenance
server running
serving initial configuration
cleaning storage unit
finished cleaning storage units
backend deploy log:Starting Container
* Serving Flask app 'app'
* Debug mode: on
2025-02-09 01:31:17,680 INFO: WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on http://127.0.0.1:5000
Status changed to Awaiting User Response railway • 5 months ago
5 months ago
Thank you for your continued help, Brody. After adding gunicorn to my requirements.txt file, I rebuild and deployed successfully. However, when I call the app, I still get the same error. Here is the deploy log:
Starting Container
Starting gunicorn 23.0.0
[INFO] Listening at: http://0.0.0.0:8080 (1)
[INFO] Using worker: sync
[INFO] Booting worker with pid: 4
Status changed to Awaiting Railway Response railway • 5 months ago
5 months ago
Please see our docs on the topic -
https://docs.railway.com/reference/errors/application-failed-to-respond
Status changed to Awaiting User Response railway • 5 months ago
5 months ago
Amazing help, Brody, on a Saturday night. Raleway is lucky to have you!
I used the Settings for each service and used the port detected by Raleway. It worked, yay, I am so happy!
Status changed to Awaiting Railway Response railway • 5 months ago
Status changed to Awaiting User Response railway • 5 months ago
Status changed to Solved brody • 5 months ago