rails7 heroku deployment failure (internal server error) - ruby-on-rails

trying to deploy my rails7 app to heroku The home screen is coming up but whenever I click on a link to another page I get a screen saying "sorry something went wrong". "if your the application owner check the logs". an in the logs it says
Failed to load resource: the server responded with a status of 500 (Internal Server Error)

My Rails 7 app started up locally fine but failed on Heroku deployment because of class naming errors. Note that Rails 7 uses Zeitwerk as its autoloader. You can test this locally by running: bundle exec rake zeitwerk:check

Related

Heroku ECONNREFUSED error: can deploy and set variables but can't run console commands

I'm on Ubuntu 20, working on a Rails 7 project. I've succesfully created a Heroku app using heroku create appname and then deployed the Rails app using git push heroku master.
The app/website is accessible and works fine on Heroku, but I'm not being able to run most console commands using the Heroku cli.
I can deploy as described above, and also set environment variables via heroku config:set TWILIO_KEY='123', but commands like heroku run rails db:migrate, heroku run rails console and most if not any other commands that I try to run via heroku run command return the following error (IP changes every time):
Running rails console on ⬢ appname... done
Error: connect ECONNREFUSED 54.175.164.234:5000
Right after I run any of these commands from my console, I can see the app logs on Heroku updating accordingly and throwing an error.
For example, for the heroku run rails console command executed above, the app logs show:
2022-05-31T00:42:11.048694+00:00 app[api]: Starting process with command `rails console` by user email#email.com
2022-05-31T00:44:34.314621+00:00 heroku[run.6356]: Awaiting client
2022-05-31T00:44:34.307905+00:00 heroku[run.6356]: State changed from starting to up
2022-05-31T00:45:04.332589+00:00 heroku[run.6356]: Process exited with status 128
2022-05-31T00:45:04.332006+00:00 heroku[run.6356]: Error R13 (Attach error) -> Failed to attach to process
2022-05-31T00:45:04.389840+00:00 heroku[run.6356]: State changed from up to complete
The Heroku docs do not provide more information on R13 or status 128 error codes.
The error code itself does not provide any other information regarding the connection to what is failing either. Could it be the DB? The connection to Heroku itself is clearly not the problem.
Any help would be appreciated.
This problem was related to my ISP blocking connections using port 5000, and it was evident when running a telnet I could not connect directly to the server either.
A workaround that works if you can't get your ISP to fix it is using a VPN.

RadRails: An internal error occurred during: "Starting Server"

I've decided to learn some Ruby on Rails, but unfortunately I can't get the testing server to work. When I try to fire it up I get this message: RadRails: An internal error occurred during: "Starting Server", and when I click OK in the message window the server's status is frozen at Starting. I get no other errors or messages.
I use the RadRails - EasyEclipse for Ruby and Rails IDE (latest version as far as I'm concerned) and I've followed these instructions to set everyting up: http://www.easyeclipse.org/site/distributions/ruby-rails.html.
The Apache server is up and running when I click the Manage Servers-tab in Bitnami Ruby Stack
Any help is appriciated.

app works on Heroku, but server error accessing DB through console

I have a Rails app on Heroku that works fine when I access it through a browser. It's also displaying data from the database correctly. However, when I try to update the database through the console, I'm getting an internal server error message. The model's name is Total.rb (table's name is "totals") I'm doing this to get the first entry
t = Total.first
! Internal server error
Since the app's working through the browser, I'm not sure if this is a problem I'm causing or if it's heroku's fault. It's been a while since I updated through the console, so I'm not sure if I'm doing it right, but that seems pretty straightforward.
I had always accessed the console with 'heroku console' now it's telling me to use 'heroku run console' but when I did that, it told me that the heroku gem has been deprecated and I need to install the Toolbelt. I installed the Toolbelt, authenticated, and tried to run a console session but same result.
Here's my Heroku info
Addons: heroku-postgresql:dev
pgbackups:plus
zerigo_dns:basic
Dynos: 1
Git URL: git#heroku.com:blahblah
Owner Email: blahblah#gmail.com
Repo Size: 19M
Slug Size: 4M
Stack: bamboo-mri-1.9.2
Web URL: http://blahblah.com
Workers: 0
Update
If I try to run the console after installing the Heroku toolbelt, I get
heroku run console
Running `console` attached to terminal... up, run.3213
bash: console: command not found
I was having the same problem there is some internal issue going on with the heroku CLI client that I don't understand.
The solution posted in this stackoverflow thread solved it for me:
Here is the link
Could Total be a reserved word? You could try renaming the table or creating a temp one, then testing the same query with that. If nothing else it will eliminate one possible problem area.

Why is my rails.png 404 for a new app of rails?

I just added a new Rails app on my server (Phusion Passenger with Apache), but the assets/rails.png is not found. Could someone explain why this would happen for a new app? and how can I fix it and prevent it in the future new apps?
Try running webrick on your dev machine with
rails s -e production
or check the log on the server to see what error you get. Most likely you haven't compiled the assets with:
rake assets:precompile
that will give you a no route error on images. See this page for asset pipeline details.

check 500 internal server error in production mode in rails 3.2

I have my app in production mode in my linode account and I get in one page a 500 internal server error the message:
We're sorry, but something went wrong.
However in my development environment works fine this page.
How can I debug this error?
How can I see the error origin in my production mode?
I want that rails show errors in production mode.
How can I do it?
Thank you!
If you have access to ssh, log in to your server via ssh and go to your rails log directory, which is inside your rails directory.
Once you are there run the command tail production.log . If this doesn't give you enough information you can also do a tail -n100 production.log (gives you last hundred lines of the production log).
If you have deployed via heroku, then you can access the logs by running heroku logs in your local console. (more information here https://devcenter.heroku.com/articles/logging)
I also find it helpful to use the exception_notification gem https://github.com/rails/exception_notification when running in production, as it emails you a stacktrace when an error occurs. Plenty of others also use Hoptoad (http://hoptoadapp.com/) or Exceptional (http://www.exceptional.io/) however i prefer the simple exception_notification gem.
Also, in some rare occasions when i can't trace the error as a final measure i sometimes open up port 3000 temporarily on the remote server firewall and cd to the rails project and run rails server production with the log level set to debug in config/environments/production.rb so i can see the error in the console, and then close off the port when i have finished.
Hope that helps.
tail -n100 production.log
will only show the last 100 lines of the log file. Just in case you want to see the log running in real time.
use this
tail -1000f log/production.log

Resources