By cgmendla
I’m trying to get a simple ruby on rails app running. I created a droplet with
My unicorn.rb is a mess
# require 'rvm'
# set path to the application
app_dir = File.expand_path("../..", __FILE__)
app_path = File.expand_path(File.dirname(__FILE__) + '/..')
shared_dir = "#{app_dir}/shared"
working_directory app_dir
# require 'rvm'
# RVM.use_from_path! File.dirname(File.dirname(__FILE__))
gem_path = '/home/cgmadmin/.rvm/rubies/ruby-2.7.1/bin/ruby'
gem_home = '/home/cgmadmin/.rvm/rubies'
# Set unicorn options
shared_dir = "#{app_dir}/shared"
working_directory app_dir
# Set unicorn options
worker_processes 2
preload_app false
timeout 30
# Path for the Unicorn socket
listen "#{shared_dir}/sockets/unicorn.sock", :backlog => 64
# Set path for logging
stderr_path "#{shared_dir}/log/unicorn.stderr.log"
stdout_path "#{shared_dir}/log/unicorn.stdout.log"
# Set proccess id path
pid "#{shared_dir}/pids/unicorn.pid"
Some output from StdError
, [2020-09-25T03:55:20.548399 #107271] INFO -- : unlinking existing socket=/home/site/christopherg/shared/sockets/unicorn.sock
I, [2020-09-25T03:55:20.549976 #107271] INFO -- : listening on addr=/home/site/christopherg/shared/sockets/unicorn.sock fd=7
F, [2020-09-25T03:55:20.550193 #107271] FATAL -- : error adding listener addr=0.0.0.0:80
/home/cgmadmin/.rvm/gems/ruby-2.7.1/gems/unicorn-5.7.0/lib/unicorn/socket_helper.rb:165:in `bind': Permission denied - bind(2) for 0.0.0.0:80 (Errno::EACCES)
from /home/cgmadmin/.rvm/gems/ruby-2.7.1/gems/unicorn-5.7.0/lib/unicorn/socket_helper.rb:165:in `new_tcp_server'
from /home/cgmadmin/.rvm/gems/ruby-2.7.1/gems/unicorn-5.7.0/lib/unicorn/socket_helper.rb:145:in `bind_listen'
from /home/cgmadmin/.rvm/gems/ruby-2.7.1/gems/unicorn-5.7.0/lib/unicorn/http_server.rb:243:in `listen'
from /home/cgmadmin/.rvm/gems/ruby-2.7.1/gems/unicorn-5.7.0/lib/unicorn/http_server.rb:878:in `block in bind_new_listeners!'
from /home/cgmadmin/.rvm/gems/ruby-2.7.1/gems/unicorn-5.7.0/lib/unicorn/http_server.rb:878:in `each'
from /home/cgmadmin/.rvm/gems/ruby-2.7.1/gems/unicorn-5.7.0/lib/unicorn/http_server.rb:878:in `bind_new_listeners!'
from /home/cgmadmin/.rvm/gems/ruby-2.7.1/gems/unicorn-5.7.0/lib/unicorn/http_server.rb:142:in `start'
from /home/cgmadmin/.rvm/gems/ruby-2.7.1/gems/unicorn-5.7.0/bin/unicorn:128:in `<top (required)>'
from /home/cgmadmin/.rvm/gems/ruby-2.7.1/bin/unicorn:23:in `load'
from /home/cgmadmin/.rvm/gems/ruby-2.7.1/bin/unicorn:23:in `<main>'
from /home/cgmadmin/.rvm/gems/ruby-2.7.1/bin/ruby_executable_hooks:24:in `eval'
from /home/cgmadmin/.rvm/gems/ruby-2.7.1/bin/ruby_executable_hooks:24:in `<main>'
I, [2020-09-25T04:19:01.549786 #107699] INFO -- : unlinking existing socket=/home/site/christopherg/shared/sockets/unicorn.sock
I, [2020-09-25T04:19:01.551237 #107699] INFO -- : listening on addr=/home/site/christopherg/shared/sockets/unicorn.sock fd=7
F, [2020-09-25T04:19:01.551475 #107699] FATAL -- : error adding listener addr=0.0.0.0:80
/home/cgmadmin/.rvm/gems/ruby-2.7.1/gems/unicorn-5.7.0/lib/unicorn/socket_helper.rb:165:in `bind': Permission denied - bind(2) for 0.0.0.0:80 (Errno::EACCES)
from /home/cgmadmin/.rvm/gems/ruby-2.7.1/gems/unicorn-5.7.0/lib/unicorn/socket_helper.rb:165:in `new_tcp_server'
from /home/cgmadmin/.rvm/gems/ruby-2.7.1/gems/unicorn-5.7.0/lib/unicorn/socket_helper.rb:145:in `bind_listen'
from /home/cgmadmin/.rvm/gems/ruby-2.7.1/gems/unicorn-5.7.0/lib/unicorn/http_server.rb:243:in `listen'
from /home/cgmadmin/.rvm/gems/ruby-2.7.1/gems/unicorn-5.7.0/lib/unicorn/http_server.rb:878:in `block in bind_new_listeners!'
from /home/cgmadmin/.rvm/gems/ruby-2.7.1/gems/unicorn-5.7.0/lib/unicorn/http_server.rb:878:in `each'
from /home/cgmadmin/.rvm/gems/ruby-2.7.1/gems/unicorn-5.7.0/lib/unicorn/http_server.rb:878:in `bind_new_listeners!'
from /home/cgmadmin/.rvm/gems/ruby-2.7.1/gems/unicorn-5.7.0/lib/unicorn/http_server.rb:142:in `start'
from /home/cgmadmin/.rvm/gems/ruby-2.7.1/gems/unicorn-5.7.0/bin/unicorn:128:in `<top (required)>'
from /home/cgmadmin/.rvm/gems/ruby-2.7.1/bin/unicorn:23:in `load'
from /home/cgmadmin/.rvm/gems/ruby-2.7.1/bin/unicorn:23:in `<main>'
from /home/cgmadmin/.rvm/gems/ruby-2.7.1/bin/ruby_executable_hooks:24:in `eval'
from /home/cgmadmin/.rvm/gems/ruby-2.7.1/bin/ruby_executable_hooks:24:in `<main>'
I do not have this tied to a domain yet.
etc/nginx/sites-enabled
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /home/site/christopherg;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
I’m not sure if I need to start unicorn manually with something like
bundle exec unicorn -c config/unicorn.rb -E production -p 80
The following looks wrong to me.Sometimes I see unicorn processes running
ps aux | grep unicorn
cgmadmin 107780 0.0 0.0 8160 728 pts/0 S+ 04:31 0:00 grep --color=auto unicorn
I think I need to generate the secret key base but I didn’t think that would cause this issue. If I try to run webbrick with the following command I get an error about the secret keybase
RAILS_ENV=production rails server --binding=167.71.190.163
Internal Server Error
Missing `secret_key_base` for 'production' environment, set this value in `config/secrets.yml`
WEBrick/1.6.0 (Ruby/2.7.1/2020-03-31) at 167.71.190.163:3000
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
This comment has been deleted
Hey there @cgmendla,
Happy to hear that you’ve got the Rails server running by adding RAILS_ENV=development rails server –binding=167.71.190.163.
What is the exact error that you get when you try to run Nginx?
Note that you can’t have the two services running on the same port, for example, you should have Nginx running on ports 80 and 443 and Rails on a different one.
One more thing that I could suggest is going through this answer here on how to troubleshoot common Nginx problems:
Hope that this helps! Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.