Rails only responds when accessed from local machine - ruby-on-rails

I'm running a Rails application on a Mac Mini server machine (with Webrick, running ruby 1.9.2 using rvm). It works fine when I run it locally on my MacBook, and it was working before I reinstalled rvm, but now whenever I try to access it from a browser on my local machine, it simply hangs and doesn't respond.
If I do a curl http://0.0.0.0:3000 on my server, though, I get the webpage back fine.
I created a fresh Rails app just to double-check it wasn't a problem with my app, and I get the same problem. I also get the problem with Mongrel, and if I try running a bare Sinatra app with Thin.
It sounds like the same problem documented here: Webrick is very slow to respond. How to speed it up?, but I tried modifying my config.rb file to use :DoNotReverseLookup => true, and it didn't help.
Any ideas?

I don't think the issue is related to Rails or your dispatcher. It looks like the OS firewall is blocking ingoing requests to port 3000. Did you try to allow all ingoing connections from your System Preferences ?

Related

Action_caching not working when using thin

I have an application running on my development machine using Aptana & Webrick.
If I turn on caching (action_caching, written to tmp/cache), it works fine, but when I deploy the application to the testserver (running thin instead of webrick) the caching does not work...i.e. there are no files written to tmp/cache.
as far as I can tell, the webserver is the only difference here (even running the development-environment on the test server.
any clues?
Okay, so I found the problem: I was running thin as a windows service, which didn't shut down or restart properly when trying to do so in "Services".
Unfortunately without notice. Therefore no changes took effect..
So after restarting the server, the caching-problem dissappeared. running thin now from the command line...

Rails still hitting old database IP, even after restarting apache

I have a Rails app on a windows machine that also has a SQLServer that it used to use as it's database.
However I am trying to transition the app to use a new SQL server on a different Windows machine.
The new Machine is reachable (ping)
After changing the database.yml file with the new IP I can go into Rails console and make queries on the new machine.
However, Running the code still queries the local(old) database.
I have restarted apache.
This is driving me nuts. Why is my code still hitting the old configuration? Do I need to restart the machine completely?
Thanks
Just Try printing the TARGET_ENV and the URI that you are targeting in the Ruby code. It will tell you which IP is being hit everytime.

Running Ruby on Rails app on server

I am using Aptana Studio 3 for development of ROR apps. I used run server command and it showed you can access your app on {http//0.0.0.0:3000/}, but when I try to access this URL, it tells me to check your Internet connection. I tried several other ports also but it is not working. I have created/modified the files necessary and migrated the database successfully too. Appreciate any help in running the app over the browser. I am currently using WeBrick Server.
so, in your title you say "on server". what does that mean? when you are running it on a different machine than your own, you need to use the address of that machine or it's domain name. keep in mind that firewall rules might prevent any connection to that server.
when you are ON the machine, via ssh for example, you can try calling the then "local" rails instance with curl http://localhost:3000/ to verify that it is running.

Rails server is running, but cannot connect to localhost:3000

I am learning Ruby on Rails with railstutorial.org
I had set everything up and working fine from Chapter 1. However, all of a sudden my next app has an issue.
I run "rails server"
=> Booting WEBrick
=> Rails 3.2.9 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2012-11-15 00:45:08] INFO WEBrick 1.3.1
[2012-11-15 00:45:08] INFO ruby 1.9.3 (2012-11-10) [x86_64-linux]
[2012-11-15 00:45:08] INFO WEBrick::HTTPServer#start: pid=2752 port=3000
Seems to be working fine, just like with my previous app.
However, I try connecting to localhost:3000 , 0.0.0.0:3000 , 127.0.0.1:3000 on various browsers and they all cannot establish a connection to the server.
Some things to note:
-I was able to connect to localhost just a while ago--it just seems like it suddenly stopped working out of the blue.
-My first app was working perfectly fine, but now it doesn't work for my first app either.
-I don't have firewalls blocking the port, and my hosts file is not the problem.
-I am on Ubuntu 12.10
I almost always find solutions via search, but not this time.. so I need some help please. It's very frustrating as I feel like it's a simple problem that I spent way too long being stuck on.
Thank you.
Try running it in some other port like say 3001 as:
rails server -p 3001
If its working than than try it again on 3000 as the command above.
I thing some other software is using your 3000 port that's why its not responding.
Or for some advanced things see here
with rails 4.2.0, the server binds to localhost by default, instead of 0.0.0.0. When working with a rails in a virtual box, accessing the server from the host computer, the binding address needs to be 0.0.0.0
Start rails server with -b0.0.0.0 to make the rails server accessible from the host computer/browser.
http://guides.rubyonrails.org/4_2_release_notes.html#default-host-for-rails-server
https://github.com/samuelkadolph/unicorn-rails/issues/12#issuecomment-60875268
Make sure you run rake db:create before launching rails s.
I'm using rails 5.0.0.beta3 and was running into this issue. #andrewleung's answer helped me a lot.
It seems like Rails default binding address is messed up on my computer (macOS 10.11.6) ; on some others, it works fine.
The simple solution is just to use rails server -b 127.0.0.1. You can then access your localhost:3000.
My guess here is (hinted from https://serverfault.com/a/544188) that localhost binding is messed up on my computer whereas 127.0.0.1 is more specific.
I had the same issues and i realized it was in the config/environment/production.rb file where config.assets.compile = false must be changed to config.assets.compile = true
However this might in a way render some javascript and sass elements unworking
The issue that it turned out I was having was that my VM had run out of hard drive space and there wasn't even enough left to create the server.pid file. For some reason though, it wasn't throwing an error for this, as the file was being created, but was left blank.
I run into the same issue. It turned out that browser-sync is also running on localhost:3000.
Due to some Rails developer would use browser-sync to test out the front end scripts quickly, I think that could be a popular reason that port 3000 is used.
check your /etc/hosts file..is ip 0.0.0.0 or localhost pointing to some other address.
for me...I was behind a proxy at work and had to do rails s -b 0.0.0.0 -p 3000

Rails Dev Server not visible on network

Trying to do something very basic and test my Rails app on my phone.
Starting the server with:
rails s
But when accessing mymachinename.local:3000, Mobile Safari says that the server stopped responding after about 30 seconds.
I do this all the time on other machines, but I have no idea what could be causing it here. Any suggestions?
I've had a similar issue before trying to access the server from a virtual machine, I had to use the following format for the rails server command:
rails s -b your.dev.ip.address
Whoops. Firewall. Don't know why I even had it turned on.

Resources