Bun static site
reallysnazzy
HOBBYOP

2 months ago

I have a Bun static site that I'm trying to use on Railway. I was able to get it to detect how to build Bun by adding 'bun run build' start command in the UI, but not able to get it to host the static site for me. AI seems to think it will automatically detect it, but it isn't. Do I need to setup a dockerfile to run Caddy to host these, or can Railway do this for me?

Solved$10 Bounty

24 Replies

reallysnazzy
HOBBYOP

2 months ago

I tried adding a public Railway subdomain, but no luck. Getting an error message


reallysnazzy
HOBBYOP

2 months ago

Screenshot_2026-04-06_18-36-18.png

Attachments


Did you map the port correctly?


Make sure the port your site is hosted on is the same port your URL is mapped to.


reallysnazzy
HOBBYOP

2 months ago

I did port 80


reallysnazzy
HOBBYOP

2 months ago

Let me try 443


reallysnazzy
HOBBYOP

2 months ago

No luck with 443 either.


Well this depends on what port Bun is using to host the site.


2 months ago

You have to set the PORT env variable to match


2 months ago

Lemme find docs


reallysnazzy
HOBBYOP

2 months ago

Bun isn't hosting the site, I'm building static html files using bun


-# That's if Bun uses PORT no?



You'll need some kind of proxy (eg, Nginx) to forward traffic to the site if nothing's hosting your site right now.


reallysnazzy
HOBBYOP

2 months ago

How can I configure Caddy or Nginx to do this? I tried using Caddy template, but I couldn't figure out how to feed the build to Caddy


2 months ago

Oh alright in that case you might need to setup a proxy like caddy or nginx to actually serve the content.


Well, one way is to use a Dockerfile.


2 months ago

Alternatively



2 months ago

You could use a package like this or the bun server to serve your dist folder


That too.

There are lots of ways to host a static site.



reallysnazzy
HOBBYOP

2 months ago

I ended up using Dockerfile with caddy


2 months ago

Good choice!


Status changed to Open medim about 2 months ago


Status changed to Solved brody about 1 month ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...