502 gateway error on frontend and backend
todiane
HOBBYOP

a year ago

I am completely new to railway and very new to deployment. I have a couple of sites up at Heroku and was hoping to move here but for the last week or more I have struggled to get my site up. First connecting database with project (I think that is done now) and now just seeing the site. I have a Django backend with a Next Js frontend. Yesterday the backend had a 502 error. today the frontend now has the same 502 error as well. How do I fix this? Appreciate guidance/help but bare in mind you are talking to a 5 year old lol so keep the language simple please. Thanks alot.

To be honest I almost gave up and went back to my other sites but I read a post in the forum where someone said they struggled on the trial plan until they upgraded and then everything worked ok. So I upgraded and appreciate any help to get this working.

Solved

7 Replies

a year ago

For your frontend please see this docs page -

https://docs.railway.com/guides/fixing-common-errors#application-failed-to-respond

For your backend, please see your deploy logs -

No migrations to apply.

Your models in app(s): 'django_summernote' have changes that are not yet reflected in a migration, and so won't be applied.

Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.

After you follow those instructions, you will likely also need that link above.


todiane
HOBBYOP

a year ago

Thank you Brody.

I have read the docs. I have Node set up to Port 3000 and Gunicorn set up via my Docker. Unless I am missing something glaring obviously I just can't see what I need to do. I have been over and over so many different things so many times for days now. I thought it was as simple as set up your variables, make sure they match your env file and you are good to go.

I have tried a number of times to run manage.py migrate in many different ways on many, many days and I get the same response
Operations to perform:

Apply all migrations: django_summernote

Running migrations:

No migrations to apply.

I even had help from someone who knows Railway well and he couldn't help me figure it out.


a year ago

> I have Node set up to Port 3000

Per your frontend's deploy logs -

▲ Next.js 14.2.17

- Local:        http://7f98750d0fb6:8080
- Network:      http://[fd12:ba6c:b185::66:db16:4659]:8080

That port 8080, it's a fair bit different than 3000 haha, I'd advise you to look at this picture again for how to properly set the domain's port.

Also, per the docs page I linked - your web server should be available at the host 0.0.0.0 -

I'm not sure where your application is getting the hosts 7f98750d0fb6 or [fd12:ba6c:b185::66:db16:4659] from but it's not what the docs were instructing.

As for the Django app, your deploy logs instructed you to run two commands.. have you? there's not too much I can help you with on that front since the Django migration stuff has nothing to do wth the platform.


todiane
HOBBYOP

a year ago

Did I mention I have no clue what I am doing lol
It has taken me longer to try to deploy this site than it did to build it. I have no idea where you go to see the Next JS info but I am not seeing it.

What I do know is that I managed to get 4 ticks on the frontend and the site reappeared.
Initialization, Build, Deploy and Post-deploy. The 502 error went away on the frontend.

The backend has the first 3 ticked but not Post-deploy and the 502 error is still there.

I have spent another day trying to correct this and uploading various suggestions from ChatGPT and Claude ai

Then I read a post in this forum from 5 months ago that said Post-deploy was a UI bug and doesn't mean anything.

https://help.railway.com/questions/what-does-post-deploy-mean-df4fa6c1

Everything has been updated to 8080 but obviously I am still missing something
I dont need help with summernote. i know it isn't the issue here. I have removed it for now until this is sorted so it doesn't distract.
Are you able to help me pinpoint where I am going wrong?


a year ago

> I have no idea where you go to see the Next JS info but I am not seeing it.

Right here.

> Then I read a post in this forum from 5 months ago that said Post-deploy was a UI bug and doesn't mean anything.

This is still true.

> Are you able to help me pinpoint where I am going wrong?

This is your start command - python manage.py migrate && gunicorn config.wsgi:application --bind 0.0.0.0:$PORT

There is absolutely nothing wrong with it, but take note that you are running python manage.py migrate before running gunicorn.

So that means gunicorn won't run unless python manage.py migrate exits, meaning something you have done in your code is preventing the migration from exiting.


todiane
HOBBYOP

a year ago

I appreciate your help with this Brody. I managed to get it from a 502 to a 400 and then figure it out. Django's host header validation was the issue. The journey continues... slightly_smiling_face emoji


a year ago

Awesome, glad you got it working!


Status changed to Solved brody over 1 year ago


Loading...