9 months ago
Hi,
I'm getting a "failed to load resource: net::ERR_CONNECTION_REFUSED" on signup form submission though Front, Back and PostgreSQL have deployed successfully on Railway dashboard.
link: https://frontend-production-28c9.up.railway.app/signup
In terms of structure I have a monorepo so I have deployed in 3 services:
frontend
backend
postgresql
Regarding the database, I'm in multi-tenancy mode, so I have 2 schemas: public and tenant.
All my table are in tenant.
Everything appears correctly in pgAdmin and directly in the terminal when connected to the railway database.
What can I do to fix that?
Thanks,
Rita
29 Replies
9 months ago
Hello,
Your backend domain returns a 502, for this error, please see this docs page -
https://docs.railway.com/reference/errors/application-failed-to-respond
Best,
Brody
Status changed to Awaiting User Response Railway • 9 months ago
brody
Hello,Your backend domain returns a 502, for this error, please see this docs page -https://docs.railway.com/reference/errors/application-failed-to-respondBest,Brody
9 months ago
I've tried changing it to everything possible and it doesn't work...I don't know what to do and I've already seen that doc.
Status changed to Awaiting Railway Response Railway • 9 months ago
brody
Hello,Your backend domain returns a 502, for this error, please see this docs page -https://docs.railway.com/reference/errors/application-failed-to-respondBest,Brody
9 months ago
I've added my domain (from OVH) and changed the environment variables and now I have:
Failed to load resource: the server responded with a status of 404 ()
Client-side error: Error during signup
Any ideas on how to solve this?
9 months ago
Hello,
I followed the docs and applied the needed changes, and your backend service domain now works.
Best,
Brody
Status changed to Awaiting User Response Railway • 9 months ago
brody
Hello,I followed the docs and applied the needed changes, and your backend service domain now works.Best,Brody
9 months ago
Hi,
What have you done exactly?
We were fixing with my husband (much more senior than me).
Thanks,
Rita
Status changed to Awaiting Railway Response Railway • 9 months ago
9 months ago
I set the target port correctly -
https://docs.railway.com/reference/errors/application-failed-to-respond#target-port-set-to-the-incorrect-value
Status changed to Awaiting User Response Railway • 9 months ago
brody
I set the target port correctly -https://docs.railway.com/reference/errors/application-failed-to-respond#target-port-set-to-the-incorrect-value
9 months ago
The port on backend has disappeared...?
Have you inserted something else or just removed it?
It's not working...404 still.
Status changed to Awaiting Railway Response Railway • 9 months ago
9 months ago
Please see the docs page I linked, it shows what I changed and where I changed it.
As for the 404, you are liking calling your frontend domain to do the login when you need to call the backend domain.
And please know that you are running a development server for your frontend.
https://github.com/brody192/create-react-app-starter
Copy the nixpacks.toml and Caddyfile from this repo into your repo to run a production grade web server.
Status changed to Awaiting User Response Railway • 9 months ago
9 months ago
I've changed the port to 443 meanwhile on the frontend.
All the variables are using https://www.hrnov.ai.
I have copied the two files in my repo at the root of it.
Am I supposed to change anything in them?
Status changed to Awaiting Railway Response Railway • 9 months ago
9 months ago
https://www.hrnov.ai is the frontend domain, your sign-in needs to call the backend domain.
You don't need to change anything in the Caddyfile and Nixpacks.toml files, so please push those changes.
Status changed to Awaiting User Response Railway • 9 months ago
brody
https://www.hrnov.ai is the frontend domain, your sign-in needs to call the backend domain.You don't need to change anything in the Caddyfile and Nixpacks.toml files, so please push those changes.
9 months ago
Do I need to change the variables?
Status changed to Awaiting Railway Response Railway • 9 months ago
9 months ago
Your frontend needs to call the backend domain for the sign in, that's all the advice I can provide as I do not know what or how you use environment variables in code.
Please remove the start command from your frontend's service settings.
Status changed to Awaiting User Response Railway • 9 months ago
9 months ago
I understand, bit lost...this is my first deployment
Example of the signup below.
API_URL is linked to an environment variable that calls: localhost 4000.
Do we agree on this case that it should be the backend url?
const handleSubmit = async (e) => {
e.preventDefault();
if (!validateForm()) return;
const requestBody = {
firstName: formData.firstName,
lastName: formData.lastName,
email: formData.email,
password: formData.password,
role: userType === "company" ? "company" : "candidate",
companyName: userType === "company" ? formData.companyName : undefined,
};
try {
const response = await fetch(`${API_URL}/signup`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(requestBody),
credentials: "include",
});
if (!response.ok) {
const errorData = await response.json();
throw new Error(errorData.message || "Error during signup");
}
const data = await response.json();
Status changed to Awaiting Railway Response Railway • 9 months ago
9 months ago
Your REACT_APP_API_URL
is set to the frontend domain, I've changed it to point to the backend domain.
That change is a part of your staged change.
Status changed to Awaiting User Response Railway • 9 months ago
9 months ago
Ok, there's 5 changes on Frontend side.
Anything else to change or is it good to go like this?
(thanks for your patience, you're my savior)
Status changed to Awaiting Railway Response Railway • 9 months ago
Status changed to Awaiting User Response Railway • 9 months ago
9 months ago
There's a Failed to load resource: the server responded with a status of 500 ()
Is there a problem with the server?
Status changed to Awaiting Railway Response Railway • 9 months ago
9 months ago
500 would be a code issue on your backend.
Have you looked at your deploy logs for the backend? you are trying to connect to postgres at 127.0.0.1:5432
You should be connecting by using the DATABASE_URL
variable.
Status changed to Awaiting User Response Railway • 9 months ago
9 months ago
As PG_URL, I have ${{Postgres.DATABASE_URL}}.
AS DB_HOST: postgres.railway.internal
etc.
Don't see where I have that...
Status changed to Awaiting Railway Response Railway • 9 months ago
9 months ago
You would want to use the DATABASE_URL
and only that variable in your code to connect to the database.
Status changed to Awaiting User Response Railway • 9 months ago
9 months ago
None of these?
DB_HOST
DB_NAME
DB_PASS
DB_PORT
DB_USER
Status changed to Awaiting Railway Response Railway • 9 months ago
9 months ago
Nope, That's just extra complications, using a single variable is the best path forward.
Status changed to Awaiting User Response Railway • 9 months ago
brody
Nope, That's just extra complications, using a single variable is the best path forward.
9 months ago
Ok, just changed and redeployed.
Status changed to Awaiting Railway Response Railway • 9 months ago
Status changed to Awaiting User Response Railway • 9 months ago
9 months ago
It's redeploying and building.
Status changed to Awaiting Railway Response Railway • 9 months ago
9 months ago
It's now working!
Thank you sooooo much for your help.
Without you, I would still be screaming to my screen (lo).
9 months ago
Ok now I have:
TalexaSubscription.jsx:173
GET https://backend-production-717e.up.railway.app/api/subscriptions/user/current 401 (Unauthorized)
POST https://backend-production-717e.up.railway.app/api/subscription/session 401 (Unauthorized)
When I try to add a subscription to pay it.
9 months ago
Unfortunately that's a code issue that we couldn't provide help with, but when in doubt check the deploy logs for more information!
Status changed to Awaiting User Response Railway • 9 months ago
brody
Unfortunately that's a code issue that we couldn't provide help with, but when in doubt check the deploy logs for more information!
9 months ago
Sure, thanks
Status changed to Awaiting Railway Response Railway • 9 months ago
Status changed to Solved ray-chen • 9 months ago