I'm just trying to run my server locally. I'm on Windows and using Ruby on Rails on Windows is a pain, so I am using Vagrant. I am doing all of these commands from my Vagrant shell.
I've tried rails s and rails s -b 0.0.0.0. Both give me OK responses in the terminal:
=> Rails 5.2.3 application starting in development
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.12.1 (ruby 2.6.1-p33), codename: Llamas in Pajamas
* Min threads: 5, max threads: 5
* Environment: development
However, when I go to localhost:3000 in my browser, it gives me:
This site can't be reached.
localhost refused to connect.
When I tried to curl http://localhost:3000 get:
curl: (7) Failed to connect to localhost port 3000: Connection refused
I also have the following line of code in my Vagrantfile:
config.vm.network "forwarded_port", guest: 3000, host: 3000
Really don't know what to do next. Right now, I am installing Ubuntu ISO file (will be done in 5 hours, so that's quite a bit of time) to create a VirtualBox instance as backup if this doesn't work. Hoping I can find a fix for this.
I would like to suggest you docker. Docker is not new, it was released in 2012 and since then has become one of the fastest-growing technologies in web development and devops.
Some of the advantages you will have if you start using it:
Reproducibility: A docker container is guaranteed to be identical on any system that can run docker and having a simple file you (and your team members) can run the system with the same specs really fast on another environment.
Isolation: Dependencies or settings within a container will not affect any installations or configurations on your computer.
Hub: You have thousands of well maintained images available including ruby and you can use them for faster experiment and get in the stuff that mater.
Docker is not vagrant, is a lot more and much more powerful.
Easy image upgrades: because images are versioned, it's a matter of to change a single tag.
Happy codding with the whale!
The key thing here is "localhost" on your Vagrant box and "localhost" on your machine are two different things. The port forwarding can often fix this, but if you have two Vagrant machines using the same port you may be sending traffic to the wrong one.
It's often better to get the Vagrant machine's IP and connect to that directly. If that IP keeps changing, you can lock it down:
config.vm.network "private_network", ip: "172.30.1.5"
Then you connect to http://172.130.1.5:3000/ predictably.
Resolved by running Ruby on Rails on UBUNTU VirtualBox machine.
Related
I am using two rails applications, running both with rails s and zeus s -p3001 locally. When I am trying to run my application in another machine, the server started with webbrick is running fine on another system but couldnot run zeus. PLease help me out.
I just gave the url in browser 192.168.1.111:3000 (running). And
`192.168.1.111:3001` (server not found).
I tried zeus s -b 192.168.1.111:3001 but didn't help me.
The problem is, that the zeus bind to the local address (127.0.0.1) prohibiting connections from remove hosts. The proper solution would be to setup the reverse proxy using apache2 or nginx.
http://glasz.org/2013/10/25/reverse-proxy-a-rails-app.html
https://www.digitalocean.com/community/tutorials/how-to-deploy-rails-apps-using-unicorn-and-nginx-on-centos-6-5
Alternatively you may also want to use firewall to redirect requests.
http://forum.slicehost.com/index.php?p=/discussion/2497/iptables-redirect-port-80-to-port-8080/p1
But a quick and dirty solution is to use SSH port forwarding like this:
Start zeus on remote machine on port 3000
On local machine
local-machine$ ssh -L 3001:localhost:3000 remote-machine
On local machine: Connect to localhost:3001 instead of to remote-machine:3000
http://blog.trackets.com/2014/05/17/ssh-tunnel-local-and-remote-port-forwarding-explained-with-examples.html
my host system is a windows 8.1 system
there i've running a debian 7 vm in virtual box.
I've created a new Ruby on Rails project and started the server. Server starts properly and listen on port 3000
So i added a port forwarding rule in virtual box for this port
But now when I try to reach 127.0.0.1:3333 from my host got an error page not found.
Is there something to look at?
when starting your server, use sudo rails server --binding=0.0.0.0
I am planning to have a web application.
To do so, I studied about ruby and ruby on rails. I am using linux server from amazon clouding system.
I bought a domain from godday, and I put the IP address on DNS setting. When I run 'rails s' command, I can connect to the wep page through port 3000 in such a way that domain.com:3000. However, I cannot directly connect to domain.com. How can I my domain works without port 3000?
And Do I have to run 'rails s' every time to make the wep page work? Actually I tried to use 'rails s &' to make it run in background. But it fails. How can I make the server run even though I am not connected to the linux server?
Thank you!
usually you use rails s just in development. there are quite a few ruby web servers you can choose from for your production environment: puma, passenger or unicorn to name a few.
of course all of them have their own tutorials how to set them up. for starters, i'd go with with passenger because it's integrated with nginx and apache and easily set up.
You need to specify a port, if you don't see the port it can be either 80 (http) or 443 (https).
rails server -p 80
On linux you have to be root to bind to port less than 1000, so just append sudo in front.
I recently switched my development platform from windows 7 to Linux (Debian), i copied entire app directory to Linux, now when i do git status it is showing a list of modified files, while on windows there was nothing to commit status. when i do git diff it looks like there is no change in file content it is just showing all the lines removed (-) and after that exact lines added (+).
Another issue is that the app is running file on port 3000 by rails s but when i tried to run it on port 80 by rails s -p 80 i get following error :
=> Booting Thin
=> Rails 4.1.5 application starting in development on 0.0.0.0:80
=> Run `rails server -h` for more startup options
=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
=> Ctrl-C to shutdown server
>> Thin web server (v1.3.1 codename Triple Espresso)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:80, CTRL+C to stop
Exiting
/usr/lib/ruby/vendor_ruby/eventmachine.rb:526:in `start_tcp_server': no acceptor (port is in use or requires root privileges) (RuntimeError)
I have checked that port 80 is free(apache2 was running on it and i killed it) so it should be permission issue as error told (port is in use or requires root privileges), so i again run rails server with sudo:
sudo rails s -p 80
This time i get following error:
git://github.com/bogdan/datagrid.git (at master) is not yet checked out. Run `bundle install` first.
i did bundle install and run above rails server command again but still getting same error.
If it is not an issue for you and the server starts in port 3000, I would suggest you to use that port without using sudo.
Usually when you go against conventions you drive into strange problems, as for instance, having to run the rails command as root, running into other strange problems as the one you are describing.
You are changing your development environment, make it at least at the beginning the least painful for you and follow the development conventions, which is to work in port 3000.
a) git reporting modified files - can be related to the windows newline \n\r while unix expects just a \n. You can try this.
b) As #fer suggested, try using the conventional ports, 3000, 3001, 30xx. They are less likely to clash with something else.
c) Possible issue with the gem or bundler version.
I'm using webrick to develop my rails app on Mac OS X Lion. I'm trying to access the site from another computer (for testing). The internal IP of my computer is 10.1.10.100.
Accessing 10.1.10.100 displays the page served by the apache server running on my computer.
Accessing 10.1.10.100:3000 times out, both from my computer and from another computer on the same network. I can ping 10.1.10.100. From my computer, loaclhost:3000 displays the app.
Is there are firewall I need to open up on Mac OS X or some other setting that needs to be applied?
Thanks
While starting the webrick server specify the IP on which your rails application will run (10.1.10.100 in your case) using -b option, it binds Rails to the specified IP.
rails server -b 10.1.10.100 -p 3000