7 days ago
I deployed an Astro app, deployments is fine, deploy logs is fine but I get a 502 Bad Gateway error when I go to the deployment url.
The app runs on port 4321 and the is setting in the Railway settings.
What could be the issue?
1 Replies
7 days ago
hey! 502 means ur app built successfully but Railway can't connect to it. this usually happens when Astro isn't binding to the right host.
add this environment variable in Railway:
HOST=0.0.0.0Astro by default binds to localhost which Railway can't access from outside the container. setting HOST=0.0.0.0 makes it listen on all network interfaces.
also double-check:
your start command should be
npm run preview(notnpm run dev)make sure you're using the Node adapter in your
astro.config.mjs:
import node from '@astrojs/node';
export default defineConfig({
output: 'server',
adapter: node({
mode: 'standalone'
})
});PORT is already set to 4321
after adding HOST=0.0.0.0, redeploy and it should work. if it still doesn't, share your deploy logs and I'll take a look!