My OS: Windows 10
Shell: Ubuntu (from the Microsoft Store)
Rails: 5.0.6
Ruby: 2.4.2
I installed Ruby on Rails using the Ubuntu Shell for Windows. After installing Ruby on Rails, I created a new project (testapp), and I am trying to connect to localhost:3000.
After a lot of searching, checking my /etc/hosts, checking my host file on windows, uninstalling eset, uninstalling XAMPP, Ruby on Rails still refuses to connect to localhost:3000.
I tried to bind it to a different port (multiple times), for example I tried to change it to port 3001, or port 4000, and it still wouldn't work. I tried rails s -b 0.0.0.0, this still doesn't work. I also tried 127.0.0.1, 127.0.0.1:3000, etc.
In the image, I am just showing that I tried rails s to connect to localhost:3000.
Can anybody please help me on why this isn't working? I am confused.
me trying to connect rails to port 3000
Ruby and Rails Version
Related
I am new to Rails programming. I did some research, and decided to start with Rails 7, and Ruby 3.1.0.
I am following a simple online tutorial, using the standard Rails 7 stack: Sprockets, no Webpacker, Tailwind (starting to learn it), and MySQL.
I have a local MySQL server setup on my Mac, and i use mysqlworkbench to peer into the local DB.
Locally, I don't need to do anything to get the server started on my development machine. From the command line, I only need to do:
rails s
and a local web server is started on port 3000.
I have an old laptop, that I set up as an Ubuntu 20.04 machine, and is my home network, on port 10.0.0.253. I figured i can use it as a test server, so I can learn how to deploy in the real world. I installed Ruby 3.1, and Mysql on the Ubuntu machine. I also have nginx installed on it, but I don't have it configured to do anything.
On the Ubuntu machine, I can do
rails s
and then from mt Mac, I can go to:
http://10.0.0.253:3000
and I get the rails app.
Of course, when I close the terminal on the Ubuntu machine, the app stops working.
If I don't do rails s on the Ubuntu machine, if I do:
http://10.0.0.253
I get an error (can't find the site you're looking for).
I looked online, and there are a few articles about configuring nginx with Passenger, but no two recipes are the same.
My question is: When I push my code to the Ubuntu server, and I do:
bundle install
rake db:create
rake db:migrate
rake db:seed
What next? to start the server, and I can access it directly at: http://10.0.0.253
I have recently created an Amazon AMI(linux) instance on an EC2.
after doing all the yum stuff, when I do
rails server, the cmd shows no errors at all, but when i try to access http:public_ip:3000 through Firefox I get "Unable to connect"
I have already installed Ruby, NodeJs, Rails, and rvm.
I have asked on IRC and have tried rails s -b http://public_ip:3000
with
/home/ec2-user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/socket.rb:205:in >`bind': Cannot assign requested address - bind(2) for 52.48.217.79:3000 >(Errno::EADDRNOTAVAIL)
in return.
I've also tried ssh to the elastic IP, and when I do rails s -b http://public_ip:3000 I get:
[2016-01-17 01:43:23] INFO ruby 2.3.0 (2015-12-25) [x86_64-linux]
Exiting
/home/ec2-user/.rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/socket.rb:231:in >`getaddrinfo': getaddrinfo: Name or service not known (SocketError)
this is all just to make sure that rails was installed well and running(I want to see the default rails page). Can anyone help?
You want to bind to 0.0.0.0.
Rails used to do this for you by default, but starting with 4.2 it only binds to localhost by default, so the command will be rails s -b 0.0.0.0.
You'll also need to make sure you have a rule set up allowing TCP traffic to port 3000 in your EC2 security group
I have rails 4 app. this morning I open up my computer and start rails server. rails server started perfectly as ever but when in browser localhost:3000 not connecting to my app.
I've tried apt-get update my ubuntu.
I've tried rails server with other port number.
I've installed Rails 4.2 on a Ubuntu 14.04 VM to act as a development environment. When I start the rails server with rails s the server says it starts and is listening for connections on http://localhost:3000
If I try to access <IP>:3000, no page is displayed and nothing hits the logs of the rails server. If I execute curl localhost:3000 from within the machine, I get the html of my home page.
If I execute rails s -b 0.0.0.0, I can access the server by its IP address.
On my MacBook Pro, running rails s (listening to localhost) allows me to access the rails app via localhost:3000 or <IP>:3000.
Ubuntu 14.04.1
Rails 4.2
http://edgeguides.rubyonrails.org/4_2_release_notes.html#default-host-for-rails-server
Rails 4.2 release notes say, that now default host for rails server is localhost.
So if you want to access app from another machine, use
rails server -b 0.0.0.0
Probably your Macbook Pro uses older Rails version, with old behavior
I have been using Mongrel successfully with rails 2.* and 3.0* development, with ruby 1.8.7.
I recently started working with Rails 3.1 and ruby 1.9.2. I got my test app running with WEBrick. I don't like WEBrick. If I forget and simply close the WEBrick terminal window instead of going into the window and issuing a Control-C to WEBrick, the server port (3000) stays in use, and I can't run 'rails server' again until I log out everything and get WEBrick cleared out of the port table. Mongrel never had that problem.
I do have a build problem with Mongrel and ruby-1.9.2. I get multiple header files in the build, some referring to ruby-1.9.1 and some ruby-1.9.2. What a mess.
What is the recommended development web server for my config, which is 32-bit Ubuntu Natty with Rails 3.1 and ruby 1.9.2?
Webrick works well for me. The only problem I had is that it did not work well with https secure. The solution was to only run https on staging and production, not on development machine.
I use the dev machine only as the server, and develop on Windows machine with Notepad++. I think it works well, after using a horrible Rails IDE. (I used to use Visual Studio and love it.) Access the web page through local IP and port. It's a cheap, fast easy solution for Windows users.
I am running Ubuntu 11.04, Rails 3.07, Ruby 1.92 with RVM, and PostgreSQL. RVM is supposed to make life easy for Ubuntu users, because Ubuntu uses a different version of Ruby.
To kill the server process running on port 3000: xxxx is the value returned from the first line.
$ lsof | grep 3000
$ kill -9 xxxx
This could easily be combined into one line or an alias killserver or similar.
Thanks for the various port listener kill commands, I will construct something simple to clear the WEBrick's irritating habit, and continue to use it. Chasing a development web server issue is low on my priority list; they should just work.
You can see from my questions that my Linux skills don't go very deep into the kernel.