Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby on Rails : is IP port 3000 locked out for external access, on Rails 4.2?

I run 2 versions on my RoR application on my computer: One is for demos (stable state, RoR 4.0), the other one is for development (RoR 4.2). Both versions can be accessed using http://localhost:3000.

But I noticed an annoying difference: The Demo version can be accessed from another computer on the network. The Dev version cannot. This will be a big trouble when the Dev version is stabilized and becomes the Demo. My customer wants to test on his own laptop, through the wlan.

Is there a "firewall" feature newly implemented ? Is it one of my Gems ?

I would be glad if someone can explain to me this changed behaviour !

Server is Webrick WEBrick 1.3.1 for both environments. Here are my gem files:

Development (not accessible from another computer)

source 'https://rubygems.org'
ruby '2.2.0'

gem 'rails', '~> 4.2.0'
gem 'bootstrap-sass', '~> 3.3.3'
gem 'sass-rails',   '~> 5.0.1'
gem 'coffee-rails', '~> 4.1.0'
gem 'uglifier', '~> 2.7'
gem 'bcrypt', '~> 3.1.10'
gem 'jquery-rails', '~> 4.0.3'
gem 'turbolinks', '2.5.3'
gem 'jbuilder', '~> 2.2.6'
gem 'bootstrap-datepicker-rails', '~> 1.3.1'
gem 'will_paginate', '~> 3.0.7'
gem 'bootstrap-will_paginate', '~> 0.0.10'
gem 'selenium-webdriver', '~> 2.44.0'
gem 'sequenced', '~> 2.0.0'
gem 'annotate', '~> 2.6.5'
gem 'rspec-rails', '~> 3.2.0'
gem 'capybara', '~> 2.4.4'
gem 'factory_girl_rails', '~> 4.5.0' 

group :doc do
  gem 'sdoc', '0.3.20', require: false
end

# gem for dev and test only
group :development, :test do
  gem 'pg'  
end

# gem for ORACLE POC
group :ORACLE do
  gem 'ruby-oci8', '~> 2.1.7'
 gem 'activerecord-oracle_enhanced-adapter', github: 'rsim/oracle-enhanced', branch: 'rails42'
#  gem 'activerecord-oracle_enhanced-adapter', '~> 1.5.5'
end

# gem for production
group :production do
  gem 'rails_12factor'
  gem 'pg'
end

Demo (can be accessed from external computer)

source 'https://rubygems.org'
ruby '2.0.0'

gem 'rails', '~> 4.0.0'
gem 'bootstrap-sass', '2.3.2'
gem 'sass-rails',   '~> 4.0.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'uglifier', '2.1.2'
gem 'bcrypt', '~> 3.1.0'
gem 'jquery-rails', '~> 3.0.4'
gem 'turbolinks', '1.3.0'
gem 'jbuilder', '1.4.2'
gem 'bootstrap-datepicker-rails'
gem 'will_paginate', '3.0.4'
gem 'bootstrap-will_paginate', '0.0.9'
gem 'selenium-webdriver', '2.42.0'
gem 'sequenced'

group :doc do
  gem 'sdoc', '0.3.20', require: false
end

# gem for dev and test only
group :development, :test do
  gem 'pg'
  gem 'annotate', '2.5.0'
  gem 'rspec-rails', '2.14.0'
  gem 'capybara', '2.1.0'
  gem 'factory_girl_rails', '4.2.0'
end
# gem for ORACLE POC
group :ORACLE do
  gem 'ruby-oci8', '~> 2.1.0'
  gem 'activerecord-oracle_enhanced-adapter', '~> 1.5.0'
  gem 'annotate', '2.5.0'
  gem 'rspec-rails', '2.14.0'
  gem 'capybara', '2.1.0'
  gem 'factory_girl_rails', '4.2.0'
end

# gem for production
group :production do
  gem 'rails_12factor'
  gem 'pg'
end

Thanks for your help !

Fred

like image 488
user1185081 Avatar asked Nov 30 '22 18:11

user1185081


1 Answers

It does seem that Rails 4.2 doesn't allow external access from localhost:3000. Why they did this, I cannot tell you. However, one solution that worked for me just a few days ago is to change the IP address your app uses for development. So call this when starting your server:

rails s -b (address) -p 3000 -e development

Replacing (address) with your internal IP address (usually 192.168.1.x).

like image 144
Ryan K Avatar answered Dec 05 '22 02:12

Ryan K