cj.miyake
By:
cj.miyake

How do I figure out what is wrong?

August 23, 2013 9.2k views
I followed the tutorial on railscasts.com concerning deployment to a VPS and got after a couple adjustments ran cap deploy:setup and cap deploy:cold without getting back any errors. I ssh'd into my droplet and restarted both Unicorn and Nginx but now i get a "can't establish connection error." In the past I would use cpanel to take a look at the logs to see what error was being thrown...is there a way to check why my site is down?
13 Answers
Nginx is probably down. Is it listening on port 80?

sudo netstat -plutn | grep :80


Check the error logs in /var/log -- do you see anything?
Thnaks for the reply
I typed in sudo netstat -plutn | grep :80
and got
[code]
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN
808/unicorn.conf
[/code]
Nginx isn't listening on port 80 -- try starting it manually:

sudo service nginx start


Does that work? If not, what's the output of this command?

tail /var/log/nginx/error.log
@estimaterer:~# sudo service nginx start
Starting nginx: nginx.
@estimaterer:~# tail /var/log/nginx/error.log

when I typed that in nothing popped up. when i tried starting unicorn....
@estimaterer:~# service unicorn start
* Starting Unicorn web server unicorn master failed to start, check stderr log for details
[fail]

Kamal...thank you so much for the help on this. My knowledge of VPS and deployment is obviously very much lacking and I really appreciate the help.
@cj.miyake: What's the output of sudo netstat -plutn | grep :80 after you started nginx?

Unicorn is failing to start -- are you running the start command as root?

I'm really glad to help! :]
root@estimaterer:~# service nginx start
Starting nginx: nginx.
root@estimaterer:~# sudo netstat -plutn | grep :80
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN 7299/unicorn.conf
root@estimaterer:~#

and yes I am running all commands as root.
Hmm weird. Is there anything in nginx's error logs?

tail /var/log/nginx/error.log


Also check unicorn's error logs, it should be in the "stderr_path" directive in unicorn.rb.
there is nothing in the error log. man this is frustrating!
Well it looks like my rails app is installed to root@estimaterer:/home/root/apps/contests/current per capistrano and git instructions....
While there is still the rails app installed to root@estimaterer:/home/rails.
I'm guessing the site is trying to run the app in the home/rails setup. Do i have to delete the original rails installation?
@cj.miyake: You should deploy it to /home/rails instead, I'm not sure if that railscasts video covers that though.
woo hoo! getting closer (i think)

*** [err :: 192.241.194.172] /etc/init.d/unicorn_contests: 25: kill:
*** [err :: 192.241.194.172] No such process
*** [err :: 192.241.194.172]
*** [err :: 192.241.194.172] Couldn't reload, starting 'cd /home/rails/current/current; bundle exec unicorn -D -c /home/rails/current/current/config/unicorn.rb -E production' instead
*** [err :: 192.241.194.172] master failed to start, check stderr log for details
command finished in 3978ms
failed: "/bin/bash --login -c '/etc/init.d/unicorn_contests restart'" on 192.241.194.172
I believe you have to edit your virtualhost's config and unicorn's config to point to /home/root/apps/contests/current

Check unicorn's error logs, do you see anything?
Have another answer? Share your knowledge.