I am trying to deploy my rails application. After I performed cap deploy production everything worked perfectly. Then I restarted nginx server, it showed OK status.
I opened the address in Browser and I get 500 error, We're sorry but some thing went wrong!
I opened the log using less log/production.log , it is showing me all the migrations and seed running perfectly. But there is no sign of pages getting loaded.
I can't see any sign of GET requests going on! Can anyone tell me a way to get over this!
Thank you!
Related
I am following Ruby On Rails Book Tutorial, Chapter 2, toy_app
I created repository in BitBucket, https://bitbucket.org/Marium36/toy_app/src/master/
And I am learning to deploy early and often to Heroku, https://salty-wave-17330.herokuapp.com/
On my local Ubuntu VM, I can perfectly load localhost:3000 and localhost:3000/users
On Heroku I can go to https://salty-wave-17330.herokuapp.com/
However, when I go to https://salty-wave-17330.herokuapp.com/users, I get the error:
We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
The build logs look perfectly fine, https://bitbucket.org/Marium36/toy_app/src/master/build
What can be the problem?
Two things you can do:
First: Check your server logs (not build logs), this will most likely tell you where the problem is - https://devcenter.heroku.com/articles/heroku-cli-commands#heroku-logs
Secondly: Add an error monitor like Airbrake - Check out Errors and Exceptions section on this page - https://elements.heroku.com/addons
Also, build logs are only related to deploying the app, you have to check the server logs to know why your server is throwing an error.
I am recently using the rubymine(ruby on rails 4) to create web pages and once I have finished some functions and run correctly,I push my code to heroku, so I can directly run the app on the heroku.
The problem is that every function could run correctly on the heroku just like running it at local except one: There is a link in one page called "calendar" to a calendar function,I can run it correctly at local, but on heroku, it goes wrong saying "we are sorry but something went wrong"
enter image description here
someone can explain to me how could it happen? Is it a bug of the heroku system, like a compatibility issue? I have push my code to heroku and run correctly many times and it won't be wrong in the push process.
here is my heroku link: https://dashboard.heroku.com/apps/clients-to-horse
Sugession
I will recommend you, please run your application on local in production mode(environment) after assets precompile, if everything will work properly then I am sure on Heroku will run also.
After deploy on Heroku make sure for migration and assets precompile for Heroku.
You are saying error as "we are sorry but something went wrong", this always comes when we miss something from our side or code bug in the application.
I have a working RoR app that's running on Ubuntu Server, served by Nginx and Unicorn. It's using a local postgres database. I also think it's running on Sinatra instead of rails, but I'm too new to RoR to be able to say for certain.
I am attempting to create a development copy of the app to do some testing with. I'm able to do so using the source code, bundle install, and then running webbrick on my desktop. However, my developer wants to duplicate the environment that the actual production copy is running in. I cloned the server hosting the application, but when I browse to the server I get the dreaded "We're sorry, but something went wrong" error.
Here's what I've checked so for. I looked at the log files in the app/logs directory, and those haven't been updated in the last 6 days, so I suspect nothing relevant will be in them. If I run "service nginx status", it appears to be started. The database is running, and I can access it through the psql interface. Again, I'm pretty much an RoR newb... I was hoping one of you kind folks might give me some advice. Where should I look next? I'm sure it's something simple that I'm just overlooking. Thanks in advance!
In your config > environments > production.rb file change the consider_all_requests_local variable to true.
config.consider_all_requests_local = true
FYI, unicorn was not starting along with NGINX. I was able to script unicorn to start on boot, and this fixed my problem.
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
I'm having a real tough time diagnosing a 500 error from my application running in production. I've had it working before, but after re-deploying via Capastrano I am unable to get it going.
Here are the facts:
The server is setup with nginx + passenger, and I'm using
PostgreSQL.
Static assets are working properly, as in I'm able to access them just fine in a browser.
I can access the rails console via RAILS_ENV=production bundle exec rails console and perform Active Record actions (like
retrieving data from the db).
Within console, I can run app.get("/"), which returns a 500 error as well (after first showing the query that was run to load
the model).
The production.log file is never written to. I've set permissions 777 on it just for the hell of it. I've also set the log level to
:debug with nothing to show for it.
The nginx log (which passenger also uses) shows no indication of errors, it just notifies about cache misses.
Because nothing of use is being logged, I have no idea what to do here. I've tried setting full permission on the entire app directory with no help. Restarted the server multiple times, nothing. The database is there and rails can clearly communicate with it. I'm not sure what I did to get it to run the first time around. I just don't know why rails isn't outputting anything to the log.
Okay, I figured this out. The app ran fine in development mode, so I knew something production-specific was screwing it up. I went into config/environments/production.rb and changes these settings:
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false # changed from true
config.action_controller.perform_caching = true # changed from false
And then after restarting passenger, rails showed me the error w/ stacktrace. Turns out I was forgetting to precompile the asset pipeline!
Things to check
1) Are you sure you are running in production environment?
Check to see if any entries are in the development.log file
2) Set up your app to email you when a 500 error occurs with a full stack trace. I use the Exception Notifier gem but there are plenty of other solutions for this.
3) When checking your app in the console are you sure you are starting the console in production mode? It is possible that the app is not starting up at all and you just forgot to set the production param thereby thinking that the app runs fine when it doesn't.
4) Are you getting an nginx 500 error or the Rails 500 error? If nginx then it is likely that your app is not starting at all and highly unlikely that you will get any rails error in your log file. The assets are static files and navigating to them proves nothing other than that they exist.
5) Are you sure you are checking the right folder on the server? Sounds really stupid but capistrano could be deploying the app to a folder that is different to the folder that nginx is looking for for your app so double check both the folder capistrano is deploying to and the folder that nginx is looking for are the same.
Just a suggestion, I would use puma rather than passenger. It's awesome with nginx.
My problem is passenger's log file (error.log) has nothing. Then it's a rotation log issue. Run
passenger-config reopen-logs
solved my problem. More.
Have you tried running in development mode to see if the error reports itself?