25 days ago
A plain html, css and js site keeps deploying forever and eventually fails.
Pinned Solution
21 days ago
It seems a lot indeed. If you want to go the easy win way, then try to create a new project and deploy the nginx there.
I tried to run it myself to see if I would have the same issue, and everything deployed successfully for me. If by any chance the problem is still actual, try to deploy straight from the repo (if you haven't done that already).
Maybe, just maybe the issue may have happened because Railway had some minor outages 3 days ago, which are listed in here https://status.railway.com/.
eg, experienced deployment issues about 10 hours ago, updated the env variables, and it was infinitely deploying, so to speak, and the status report explains it.
13 Replies
25 days 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!
25 days ago
an nginx static site
22 days ago
did you specify port via env variable? I believe nginx default is 80
EDIT: deploy will not be seen as complete until a successful bind on port is made
22 days ago
yes port 80 is set in env variable.
This is not my first deploy to that project. Previous deploys have always been successful. I think it's something from railway.
22 days ago
i would agree that port is the issue but just port 80 would not be enough...
Railway injects a PORT environment variable that your app must listen on. The default nginx:alpine image listens on port 80, but Railway expects it to listen on the dynamic $PORT.
When nginx ignores the PORT variable and listens on 80 instead, Railway's health checks fail, and the container gets killed before producing any logs.
The fix would be that you need to configure nginx to use the $PORT environment variable.
Here's what may work for you:
1. Create nginx.conf:
server {
listen $PORT;
server_name _;
location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
}
}
2. Update your Dockerfile:
FROM nginx:alpine
# Copy custom nginx config
COPY nginx.conf /etc/nginx/templates/default.conf.template
# Copy site files
COPY site /usr/share/nginx/html
# Expose the port (documentation only)
EXPOSE 8080
# nginx:alpine automatically substitutes env vars in .template files
CMD ["nginx", "-g", "daemon off;"]
The nginx:alpine image has built-in support for environment variable substitution in files ending with .template in /etc/nginx/templates/.
project/
/---- Dockerfile
/---- nginx.conf
TL;DR
The application inside the container must listen on the port specified by the $PORT environment variable that Railway injects. EXPOSE in the Dockerfile is optional documentation and doesn't affect functionality (but it gives a good overview of what port you're planning to use). Currently, your Dockerfile does not configure nginx to listen on the correct port, and that's where the .conf comes in.
hope it helps.
zuneec
i would agree that port is the issue but just port 80 would not be enough...Railway injects a PORT environment variable that your app must listen on. The default nginx:alpine image listens on port 80, but Railway expects it to listen on the dynamic $PORT.When nginx ignores the PORT variable and listens on 80 instead, Railway's health checks fail, and the container gets killed before producing any logs.The fix would be that you need to configure nginx to use the $PORT environment variable.Here's what may work for you:1. Create nginx.conf:server {listen $PORT;server_name _;location / {root /usr/share/nginx/html;index index.html;try_files $uri $uri/ /index.html;}}2. Update your Dockerfile:FROM nginx:alpine# Copy custom nginx configCOPY nginx.conf /etc/nginx/templates/default.conf.template# Copy site filesCOPY site /usr/share/nginx/html# Expose the port (documentation only)EXPOSE 8080# nginx:alpine automatically substitutes env vars in .template filesCMD ["nginx", "-g", "daemon off;"]The nginx:alpine image has built-in support for environment variable substitution in files ending with .template in /etc/nginx/templates/.project//---- Dockerfile/---- nginx.confTL;DRThe application inside the container must listen on the port specified by the $PORT environment variable that Railway injects. EXPOSE in the Dockerfile is optional documentation and doesn't affect functionality (but it gives a good overview of what port you're planning to use). Currently, your Dockerfile does not configure nginx to listen on the correct port, and that's where the .conf comes in.hope it helps.
22 days ago
.
22 days ago
Hi, thank you, but this seems like a whole extra. Didn't do all this for my previous deploys to the same project that worked.
https://github.com/railwayapp-templates/nginx
I'm actually using the railway template. It has always worked, except now. Something changed from railway's end.
godsreal
Hi, thank you, but this seems like a whole extra. Didn't do all this for my previous deploys to the same project that worked.https://github.com/railwayapp-templates/nginxI'm actually using the railway template. It has always worked, except now. Something changed from railway's end.
21 days ago
It seems a lot indeed. If you want to go the easy win way, then try to create a new project and deploy the nginx there.
I tried to run it myself to see if I would have the same issue, and everything deployed successfully for me. If by any chance the problem is still actual, try to deploy straight from the repo (if you haven't done that already).
Maybe, just maybe the issue may have happened because Railway had some minor outages 3 days ago, which are listed in here https://status.railway.com/.
eg, experienced deployment issues about 10 hours ago, updated the env variables, and it was infinitely deploying, so to speak, and the status report explains it.
21 days ago
You're right. I just retried it and it worked. It seems to be a railway downtime. Thanks
Status changed to Solved brody • 21 days ago