railsbug
railsbug

Reputation: 13

cloud9,rails s, Permission denied - bind(2) (Errno::EACCES)

when i do the opration with the doc of cloud9 https://docs.c9.io/running_a_rails_app.html

finally, i write the code rails s -p 3000 -b 0.0.0.0

then the mistake show:

/opt/rh/ruby193/root/usr/share/ruby/webrick/utils.rb:85:in `initialize': Permission denied - bind(2) (Errno::EACCES)                                                                                                                                                               
   。。。。。。                                                                                                                                                                                                                              

     Error: you may be using the wrong PORT & HOST for your server app                                                                                                                                                                                                         

Cloud9 For rails, use: 'rails s -p $PORT -b $IP'
For Sinatra, use: ruby app.rb -p $PORT -o $IP'

whatever i try the ip and port, the mistake is the mistake .

Upvotes: 0

Views: 3725

Answers (1)

Sam
Sam

Reputation: 1253

I don't have any experience with the cloud9 IDE, but assuming you have some access to your environment ... I would try to solve this in the following ways

  1. Make sure your environment variables are correct

    echo '$PORT' # should be '3000' per your question

    echo '$IP' # should be '0.0.0.0' per your question

  2. Run your web server on port 80 with rvmsudo (port 80 because of what might be happening in your iptables -- see #2)

    rvmsudo rails s -b 0.0.0.0

  3. Modify your iptables to allow traffic on port 3000

    sudo vim /etc/sysconfig/iptables

    Add the line: -A INPUT -m state --state NEW -m tcp -p tcp --dport 3000:7010 -j ACCEPT

  4. Change the user, group and permissions on your webrick files (obviously change your 'user' and 'group'):

    sudo chown user:group /opt/rh/ruby193/root/usr/share/ruby/webrick/*

    sudo chmod 755 /opt/rh/ruby193/root/usr/share/ruby/webrick/*

When done you might want to change the permissions on your webrick files to something more strict later.

Upvotes: 1

Related Questions