By clumsyjedi
I have an Ubuntu droplet
> uname -a
Linux MYHOSTNAME 3.13.0-43-generic #72-Ubuntu SMP Mon Dec 8 19:35:06 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
I am trying to run a ruby webrick command line invocation to bind to port 9191.
> ruby -run -e httpd . -p9191
When I do this I am able to connect to the public IP of the host using curl or telnet from the droplet itself, but not from other hosts.
> curl -X GET http://MYIPADDRESS:9191
curl: (7) Failed to connect to MYIPADDRESS port 9191: Connection refused
If I change the webserver command to port 80
> ruby -run -e httpd . -p80
Then it works. What is different about port 80 in this case? How can I enable HTTP traffic to port 9191 from the outside world.
BTW iptable does not seem to have any rules setup
> iptables -nL
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
By default, that command should bind to the public interface and serve content externally. What’s the output of netstat -plunt ? You should see something similar to
# netstat -plunt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:9191 0.0.0.0:* LISTEN 1389/ruby
This means that the process is listening on all interfaces. If your content is still not available, then your problem will lay somewhere else. If for some reason, the output looks like this:
# netstat -plunt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:9191 0.0.0.0:* LISTEN 1740/ruby
Then it is only being served on the localhost. To explicitly make it available publicly, you can pass a bind-address option:
ruby -run -e httpd . -p9191 --bind-address=0.0.0.0
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.