2 months ago
I start a vite preview at port 8001, the public domain is aimed to 8001 tooIt performed a error: Application failed to respond
And the request is erred as 502 Bad Gateway:
1 Replies
2 months ago
vite preview binds to localhost (127.0.0.1) by default which isn't accessible from outside the container. that's why railway shows "connection refused" in the upstream errors. you need to add --host 0.0.0.0 to make it listen on all interfaces.
change your start command to: vite preview --host 0.0.0.0 --port $PORT or add this to your vite.config.js: preview: { host: '0.0.0.0', port: 8001 }.
make sure the port matches what you configured in railway's networking settings. that said, vite preview isn't really meant for production hosting. for a static site you're better off using something like npm install serve and then serve dist -l $PORT as your start command, or deploy to a static hosting service. vite preview is more for locally testing your production build before deploying.