502 Bad Gateway error
scotwllm
HOBBYOP

10 months ago

The project is listed as successful, and I can't find any errors anywhere, but when I try to view the site I just get a 502 bad gateway error. I've been trying to figure this out for two days. Unfortunately, I'm not very smart though.

Solved$10 Bounty

Pinned Solution

  1. I would switch to a newer version of Node, 18 is deprecated IIRC

  2. Make sure your URL is listening to that port

  3. Any error logs?

4 Replies

Railway
BOT

10 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!


scotwllm
HOBBYOP

10 months ago

server.js present at root

Express static route configured

npm start launches server (!) confirm in logs -- look for node server.js

Railway sees "start":"node server.js"

Node version modern enough (!) sugest 18.x -- add "engines":{"node":"18.x"}

Public folder routing

Server listens on process.env.PORT

Build: npm install

Start: npm start

Server: server.js using Express, static files in /public

PORT: process.evn.PORT || 8080

Node: Should be 18.x


  1. I would switch to a newer version of Node, 18 is deprecated IIRC

  2. Make sure your URL is listening to that port

  3. Any error logs?


0x5b62656e5d

1) I would switch to a newer version of Node, 18 is deprecated IIRC 2) Make sure your URL is listening to that port 3) Any error logs?

scotwllm
HOBBYOP

10 months ago

Hi there -- thanks so much for helping me. I'm not sure if your suggestion is what made it work, but I think it was because we were going back and forth between using port 4000 and 3000, and most recently we thought let's just use the port Railway recommends, 8080. I was looking through every screen I could find until I ran across something trying to use port 3000. I switched it to 8080, and I don't get the 502 Gateway error anymore.


Status changed to Solved noahd • 10 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...