Rails setup issue
Still trying to migrate over from Heroku. Server is up and running now, but when i access the webpage, i get a Railway "Application failed to respond" page. However, watching the logs, the server is responding and with no errors, so I'm really not sure what's going on.
This is a Rails app. I do notice there does not seem to be any views being processed by the Controller, which is very odd; not something I've ever experienced before.
Any thoughts?
Also is there no way to ssh in to the Railway instance, (like
heroku run console
?). railway run rails console
just seems to be my local machine 🤔
Project ID: dbb32a7b-e126-450a-89f1-55383bcf99b868 Replies
Project ID:
dbb32a7b-e126-450a-89f1-55383bcf99b8
actually, i take that back, views are rendering. I have no idea what's going on then 🤔
Why would Railway be displaying an "Application failed to respond" page when the server is responding as expected?
i think i need to set the
PORT
properly in the Procfile
. Will touch back laterDon’t set it in the procfile, set it in your environment variables
this docs page can help you out
Ok, i guess what confused me earlier in that article is that it says setting a
PORT
env variable is not recommended? In any case, i just set one to 3000
, but now the server isn't responding to requests at all 🤔
im sure im just missing something stupid?Pretty sure you should be listening on https, not http. Would be helpful to see your repo
http is the correct scheme to listen on
web: rake db:migrate && bin/rails server -b 0.0.0.0 -p ${PORT:-3000}
try this for your ProcfileOk, that’s what I was assuming initially; will try that in a bit thx
same exact result. should i remove the
PORT
environment variable?No, you need to be listening on the port environment variable since that is the traffic port provided by your container
hmm, any idea then? could it be my
puma.rb
? though im not sure that is even being used anymore with that Procfile tweakHonestly, that was the extent of my knowledge with running rails on railway. I have not done rails dev in a few years. Are you able to share your repo?
unfortunately not the whole thing, no. but i could share specific bits
Fair enough
Let me do some digging around and see if we can solve it for ya
bless 🙏
I’ll report back
unsolicited feedback, but i think this is one area where Railway is lagging behind a bit. Heroku has very clear and specific docs on how to specifically get Ruby on Rails up and running on their platform. Not finding much here on Railway; though i know they are adding things all the time.
The docs are open source, so when we find a solution, you can always contribute to them as well!
See if you can match this template up with your current configuration the best you can. I have testing this in the past and know it works
https://github.com/railwayapp-templates/ruby-rails
GitHub
GitHub - railwayapp-templates/ruby-rails
Contribute to railwayapp-templates/ruby-rails development by creating an account on GitHub.
Just as a starting point for further testing
nice! copy that, i'll run through that in a bit
Ok, so I've ended up getting further along now, but the "solution" seemed to be disabling
force_ssl
in config/environments/staging.rb
. But that's not good; we definitely want to force SSL, and that should be supported, no?
Additionally, im now back to the server responded successfully to requests, yet im still getting the Railway "Application failed to respond" 😩
indeed listening on the right port...You should not need to force ssl, as your container sits behind a reverse proxy that is already enforcing ssl connections
ok, good to know 👍
what in the heckin sorcery
i just turned
force_ssl
back on just to check something and now the app is loading perfectly fine for the first time 😂That is weird. Could have been that the rails server wasn’t rebooting properly
i dont even know what fixed it anymore 😆
Just remember, it’s not going to be 100% easy switch from platforms like Heroku. Heroku has buildpacks that are very specific build instructions.
Here it’s nixpacks which are a bit more loose and can be configured to handle a variety of situations.
You can also deploy a Dockerfile, so, if you have a working dockerfile for your project, you can deploy that as well
trying to get it up and running as vanilla as possible and just let Railway do its magic. So far, so good. but i still got a lot of stuff to work out. but at least we've finally got a working build
is there really no way to ssh into a Railway instance (even like
heroku run console
)? that seems like a potential roadblock for usThere is not a way to ssh into the instance at this time, no
dang.... any idea if there's plans to add?
They have mentioned in passing that it might be in the pipeline, but they are not 100% on it as of yet
man. gonna have to mull over that, may be a deal breaker. there's no way to run a command on the server? even through the web UI?
No, there isn't
dang. that seems untenable. how is nobody else having an issue with that?
You can set custom start commands if that’s any help
Yep
not really no
What do you need ssh access for?
You would replace your Procfile with a railway.json file. That can trigger a shell script to run your commands followed by starting your server
Just a suggestion
could be any number of things; fix an issue with a user's account, run some script, check on data, anything
hm i can't quite picture, do you have an example somewhere?
Your database should not be a part of your main app. You should have an external db (through Railway or otherwise) which you can send commands to
The reason why most users don't have an issue with not having ssh is because their app is constructed "correctly"
Their app doesn't store any data
ho boy...
What db are you using? don't say sqlite
Postgres
Okay, that's better
Your app will need a bit of retooling to get access to your data, but trust me, it's for the better
Modular programming is the way to go
you're making a lot of assumptions here
How so
our app and our DB are already separate. I realize i can access DB data directly through Postgres. but that doesn't mean there's no need to ssh into the server
This is the railway.json file for the Django starter template. It can be modified to fit your needs
For the start command, you can move your rails start commands from Procfile to a shell script, then execute the shell script from the json file, but run all your commands priory to starting the server
You mentioned you'd need to access data stored in your app. Assuming that's in a db is a valid assumption. If you do need to store files, use a cloud bucket
As for firing off commands, that won't be possible unless you build out an endpoint to hit that runs the command.
If Railway isn't the platform for you with this restriction, that's your choice
wowzers...
things were going so well
You don't need to use a cloud bucket to store files on Railway.
Right, but to access them you do, no?
Railway now has persistent storage, if you join the Priority Boarding program.
I can actually see now why people would want to SSH in, or at least FTP in.
i never even asked anything about storing files in a cloud bucket. i simply asked how to get ssh or console access, an incredibly fundamental request as far as I can imagine, and am getting told that i don't actually need to and Railway isn't for me
I asked for your usecase for ssh, that's how cloud buckets came up
We have this conversation with a new user every few days, I'm just going through the script
Railway doesn't support SSH because, up until recently, container storage was fully ephemeral and SSH access would just be confusing.
Now, though, I can see why it would be useful.
He was looking for ssh access to be able to execute commands
im not trying to store anything, i just need to interface with the Rails server.
^^^^^
as i clearly stated
Fair enough, yeah.
I'll make a feature request
thank you
My suggestion of using a shell script to run his desired commands, followed by launching his server would probably be the best method at this time
Ooh, it's already up, and it's planned: https://railway.canny.io/feature-requests/p/allow-ssh-access-to-containers-via-cli
Allow SSH access to containers via CLI | Feature Requests | Railway
I have a project that works in my local environment but not once pushed to Railway. If I could login to the container like I can locally, I could determine
You should look into Tailscale - I haven't used it, but I've heard good things about it.
I know it's more roundabout than it should be, but that's the best I can give you right now, sorry. I hope you can find more out about why your app isn't working.
thank you, will look into that. my app is actually working now, but it's very very routine to need to ssh in for some reason or another
does anyone know if this means the feature itself is under review?
That means that the feature request is under review
It's not in progress
Scroll up a bit:
Under consideration
They've decided to do it, but haven't done it yet.
right, ok