Bad gateway when using Vite - React - Caddy
mparisi76
HOBBYOP

8 months ago

The deployment is successful, however, when I try to access my app in a browser, I get a 502. I've verified the port in railway settings matches the port in Caddyfile

Solved$10 Bounty

33 Replies

mparisi76
HOBBYOP

8 months ago

eff4fdbb-16e0-4ffb-bee2-4ad13f2f307e


8 months ago

Can you access it through the Railway generated domain?


8 months ago

I wonder if it's related to your cloudflare setup


mparisi76
HOBBYOP

8 months ago

Hi, I get the following:


mparisi76
HOBBYOP

8 months ago

1387114206884794600


8 months ago

Can you try following the mentioned docs on Fixing Common Errors linked on that error page?


windspore
FREE

8 months ago

A 502 usually means your Caddy server isn’t actually serving the app on the port Railway is expecting, even if it looks like the port matches.

Make sure your Vite build is serving the production files and not just running the dev server. The Vite dev server isn’t meant for production and will cause this kind of issue.

Also double check your Caddyfile to make sure it’s pointing to the correct build folder and that Caddy is properly serving on 0.0.0.0, not just localhost.

If you’re still stuck, try testing without Caddy first to see if the app can run directly, then add Caddy back in once it works.


mparisi76
HOBBYOP

8 months ago

I checked the port and that seems to match.. I'm not sure what else to try from there


mparisi76
HOBBYOP

8 months ago

I'm not sure my Dockerfile is correct


brennenrocks
HOBBY

8 months ago

I was running into this issue as well. Please check out my thread https://discord.com/channels/713503345364697088/1386788139649073223 and see if it helps


brennenrocks
HOBBY

8 months ago

Are you sure your app is being served with Caddy? Mine wasn't


mparisi76
HOBBYOP

8 months ago

I'm not sure - kind of new to this..


mparisi76
HOBBYOP

8 months ago

I don't see anything in my log files that compares to the log files in your thread..


mparisi76
HOBBYOP

8 months ago

my deploy log:


mparisi76
HOBBYOP

8 months ago

```Starting Container

maxprocs: Updating GOMAXPROCS=8: determined from CPU quota

GOMEMLIMIT is updated

using config from file

adapted config to JSON

admin endpoint disabled

automatic HTTPS is completely disabled for server

started background certificate maintenance

HTTP/2 skipped because it requires TLS

HTTP/3 skipped because it requires TLS

server running

serving initial configuration

cleaning storage unit

finished cleaning storage units```


brennenrocks
HOBBY

8 months ago

The answer that I'm still waiting to try out is to not have a Dockerfile or a Caddyfile and don't have a "start" script in my package.json


brennenrocks
HOBBY

8 months ago

and use Railpack


mparisi76
HOBBYOP

8 months ago

cool, what time zone are you? I'll be working on this tonight also (ET)


mparisi76
HOBBYOP

8 months ago

If anyone can help, let me know. The repo I'm trying to get running is https://github.com/mercurjs/vendor-panel


8 months ago

This repo doesn't has a Dockerfile like you described earlier.


8 months ago

Are you using your own Dockerfile?


mparisi76
HOBBYOP

8 months ago

I was trying to get it to work with a Dockerfile, but I've since removed it


8 months ago

I will try to deploy it, one sec


mparisi76
HOBBYOP

8 months ago

this is what I have currently:


mparisi76
HOBBYOP

8 months ago

1387188770553729000


8 months ago

for context: https://discord.com/channels/713503345364697088/1385062839563194368
seems like it's impossible to make it work with Railpack as that project runs with Yarn@3
I didn't went too far with Nixpacks tho


mparisi76
HOBBYOP

8 months ago

I think I have tried just about everything..


mparisi76
HOBBYOP

8 months ago

I may have to switch to Vercel


mparisi76
HOBBYOP

8 months ago

!s


mparisi76
HOBBYOP

8 months ago

I finally got this working tonite so it looks like I may stay with Railway


case
PRO

8 months ago

What was the solution?


mparisi76
HOBBYOP

8 months ago

I installed caddy(not 100% sure if this was necessary), made "vite build" my build script, removed start script, removed Dockerfile and set port to 8080 (caddy default?)


8 months ago

!s


Status changed to Solved brody 8 months ago


Loading...