I'm trying to launch a simple rails app on Fargate. I've been following this tutorial: https://scoutapm.com/blog/deploying-to-aws-part-i-running-a-rails-app-on-fargate
I can see the puma server running in the logs listening on localhost:80 but when I navigate to the public IP of the ENI I can't connect to the server.
Any suggestions on what the issue could be? I've made sure the security group is open to all traffic both inbound and outbound.
binding '0.0.0.0' fixed it
rails s -p 80 -b '0.0.0.0'
Related
I have a local ruby on rails server set up on -
http://localhost:3000/
I have added allow arbitrary loads in the info.plist
When I run the app on the simulator it works fine, but when I try to run it on the iPhone it doesn't. The app just crashes.
Looking at similar questions I found that I need to use the actual IP. I also turned the Internet sharing on from the preferences.
So I found out my local IP address which is - 192.168.0.8
So in Safari I am testing it out like this http://192.168.0.8:3000/
But it doesn't work!
How can I get this up and running?
Start your rails server like this:
rails server -b 0.0.0.0
Note that if you have a firewall on your computer you may need to open your firewall or run on another port, like port 80.
rails server -b 0.0.0.0 -p 80
It'd be easier if you Ngrok.
Just start your server, as usually and by default with port 3000, and then run ngrok as to start listening on such port:
./ngrok http 3000
This will give you a public IP which will be accessible for your devices.
I am working on a rails project on cloud9 and I followed this tutorial to install PhPmyadmin.
The problem is that I can't run at the same time a rails server and a php my admin server since they both seem to use the same Port.
To launch my rails server, I use rails s -b $IP -p $PORT.
Here is the error I get:
/usr/local/rvm/rubies/ruby-2.3.0/lib/ruby/2.3.0/socket.rb:205:in `bind': Address already in use - bind(2) for 0.0.0.0:8080 (Errno::EADDRINUSE)
Has anyone an idea how to fix this?
phpMyAdmin is just another PHP application, so it doesn't listen on a port. You should instead check your webserver configuration to see what port it is on. Most webservers tend to default to port 80, though, so it might be some other process.
You can use netstat -tulpn | grep 8080 to find what's using that port and modify either your Rails configuration or the other process to use a different port.
I just using AWS, EC2.
and I run server but I cannot access localhost:3000.
I tried
rails server -b0.0.0.0
rails server -b(AWS public host)
how can I access to server...??
enter image description here
Yes rails server -b 0.0.0.0 is correct, you should be able to access it from the outside on port 3000 if your AWS environment is set up correctly (hint, check firewalls etc),
on the other hand, why would you use port 3000 to access an AWS hosted web service from the outside is a completely different matter
On your screenshot, you are not trying to reach "localhost" but your public IP. Can you try http://localhost:3000 while running rails server -b 0.0.0.0?
To access your public IP, I assume that your machine is accessible publicaly on port 22 since you ssh'd in it. So just make sure that you have opened your security group on port 3000 (and also that you don't have any DENY ACL on your subnet, but this should be OK by default if you didn't touch the ACL rules).
I'm trying to access localhost with specified port on my application on Cloud9 platform. I'm building a ruby on rails app, running a server with command below.
rails s -b $IP -p $PORT
I have a special occasion where I need to access a different port (not localhost:3000). Does anyone know how to do this?
Thanks for the help!
Cloud9 now has multiple external ports (released a few days ago but not yet documented). You can run a service on port 8081 or 8082 and it will be accessible by appending the relevant port to your preview url (e.g. http://project-user.c9.io:8081). Only http works for now, https will be available soon.
I recently have been having a problem with my AWS EC2 instances. The problem is that I cannot hit my Rails servers via public IP, but I can hit localhost and the server will respond.
Here's what I'm doing:
Create new EC2 instance (t2.micro, ubuntu free tier)
Security group has port 22, 80, 3000 open to everyone (0.0.0.0)
SSH to EC2 instance, install rails (I've been using this to install)
Start rails server after install, it's running on port 3000
run "wget localhost:3000" and it returns index.html, yay!
go to my web browser, type in EC2 instance public IP and port 3000 (IP:3000), says it can't connect :(
kill rails server, restart it on port 80, wget works but can't connect via public IP
as a sanity check, I install nginx and run it, and can see the nginx start page on port 80 via public IP... so confused...
So I'm thinking it has something to do with how I'm installing Rails, but I've tried methods other than using that install script but am encountering the same problem... I've even tried creating an entirely new AWS account just in case I screwed up the settings in my original account but haven't had any luck. I have previously been able to get rails running on EC2 instances just fine (in fact I have EC2 instances using the same security group running on my AWS account right now and can hit those public IPs just fine), but am now just banging my head against the wall... any help would be greatly appreciated!
EDIT: For now, I've configured nginx to hit my rails server.... at least that works for now... although I'm still curious why I can't hit my rails server directly...
Check if rails listens on 0.0.0.0 or 127.0.0.1, default is to listen only on localhost.
-b, --binding=IP Binds Rails to the specified IP.
Default: localhost
From the Ruby on Rails 4.2 Release Notes:
Due to a change in Rack, rails server now listens on localhost instead of 0.0.0.0 by default. This should have minimal impact on the standard development workflow as both http://127.0.0.1:3000 and http://localhost:3000 will continue to work as before on your own machine.
If you are using 'rails server' and want to use the default port 3000 then use below:
sudo rails server -b 0.0.0.0
it can be accessed as http://[public_ip]:3000.
If you want to use it as a URL without the port use the below to run the server:
sudo rails server -p 80 -b 0.0.0.0
You just access it as http://[public_ip].
I was running the rails server on default port 3000 on my AWS Ubuntu instance and had allowed this port in the security group, inbound section but still I was unable to access my application by using this.
http://public_ip:3000
I searched a lot and this answer helped me. Explaining the answer. We have to make firewall setting flexible so that our firewall allows port 3000.
You can use this command to check if this port is allowed on firewall or not.
$ sudo iptables -L | grep :3000
If you see nothing it means we have to allow it using this command.
$ sudo iptables -A INPUT -p tcp --dport 3000 -j ACCEPT
This worked for me to get my rails app access on port 3000.