Having a problem with deployment of a small Sinatra app that works fine locally, and seems like its running on digital ocean, but can't be hit via the domain name. The following is the message I receive:
This webpage is not available
Error code: ERR_CONNECTION_REFUSED
The following is what's displayed on my droplet using rackup -p 80, which to me indicates it should be able to be hit:
Thin web server (v1.6.3 codename Protein Powder)
Maximum connections set to 1024
Listening on localhost:80, CTRL+C to stop
If it makes any difference, I also cannot hit the ip address directly. Anyone encounter similar problems or possibly a solution? The app is on ubuntu uses psql as a database. It would be greatly appreciated. Thanks!
Bind your app on 0.0.0.0 instead of localhost:
ruby your_app.rb -o 0.0.0.0
or
rackup --host 0.0.0.0
In production, you should setup a reverse proxy (eg. using nginx or apache) to bind a domain to your app internal port insteal of opening everything on 0.0.0.0
Related
I am using Flutter Web and want to setup the development server for multiple devices.
I'm currently running the server like this:
flutter run -d web-server --web-port 5000
This works for http://localhost:5000 but when I try to access the server from http://127.0.0.1:5000/ even on the same machine it doesn't work.
How can make the server accessible from any device under the same network without building the app?
NEW ANSWER
Cloudflare should enable you to make a tunnel to your localhost.
On linux you can:
Install Cloudflare
Create a tunnel which point to localhost:5000 with cloudflared tunnel --url http://localhost:5000/
Use the given address to access your local development website from anywhere
Note that this is still slow. I would say it's good enough if you need to check on other devices once in a while but not if you want to develop like you would with hot reload.
OLD ANSWER (This seem to be really slow for an unknown reason)
You should look into something like ngrok.
On linux you can:
Install ngrok: sudo apt install ngrok
Create a tunnel which point to localhost:5000 with ngrok http 5000
Use the given address to access your local development website from anywhere
You need to add --web-hostname 0.0.0.0;
flutter run -d web-server --web-hostname 0.0.0.0 --web-port 5000
This tells it to listen on all addresses.
For me hostname 0.0.0.0 does not work (it works with PHP but not for Flutter)
flutter run -d web-server --web-hostname 0.0.0.0 --web-port 5000
It works when using actual local IP number of my machine
My Go application makes TLS connections via tls.Dial() to exchange data.
It works fine when run from the host:
But the outgoing connection doesn't seem to work when the app is run from a Docker container. The app hangs indefinitely.
Note 1: Same behavior with using docker run -p $(docker-machine ip):2500:2500 ...
Note 2: VM doesn't have extra port forwarding settings other than the default settings that came with docker-machine's default VM.
Docker image build with Dockerfile:
FROM golang:latest
RUN mkdir -p "$GOPATH/src/path/to/app"
# Install dependencies
RUN go get github.com/path/to/dep
VOLUME "$GOPATH/src/path/to/app"
EXPOSE 2500
WORKDIR "$GOPATH/src/path/to/app"
CMD ["go", "run", "main.go"]
Host is OS X running docker-machine.
Question
How can I make the TCP outgoing connection to work?
You are either using boot2docker or docker-machine (since you are running docker on OSX). If you are using boot2docker, you have to forward the ports on VirtualBox as well as docker, have a look at this blog post:
https://fogstack.wordpress.com/2014/02/09/docker-on-osx-port-forwarding/
If you are using docker-machine, you have to connect to the docker-machine assigned ip, not localhost, have a look at this post:
https://github.com/docker/machine/issues/710
I see now that you are using docker-machine specifically, so the post about docker-machine should answer your question.
Edit: I misunderstood the question. You are trying to make an outgoing connection on a forwarded port. That is not correct. By default docker can make outgoing connections on any port. The port forwarding is for incoming connections only. Please try again without specifying any ports to forward. My suspicion is that you are trying to make an outgoing connection on the incoming (forwarded) port.
I've just had exactly the same problem. Was unable to connect out at all.
Restarted the container, and suddenly outgoing connections worked fine. It's possible that the container survived an update of docker?
Currently using Docker version 18.09.3, build 774a1f4
How can I specify a default host and port for Padrino?
Normally I could start my process like this:
padrino start -h myhost
I want to change the default parameters of start. I expected that to be done by editing the config/apps.rb to:
Padrino.mount('MyApp::App', :app_file => Padrino.root('app/app.rb')).to('/').host('myhost')
However with the above line, Rackup still starts listening only on 'localhost'. So I assume that the host() option does not have an effect on Rack at all.
Ideally I would like to set the port/host just for "development" mode, but I cannot find the place where that setting is handed down to the rackup/webrick server.
These options are now defaulted to 127.0.0.1 for security and paranoid reasons.
To rackup here: https://github.com/rack/rack/blob/28b014484a8ac0bbb388e7eaeeef159598ec64fc/lib/rack/server.rb#L187
To padrino s here https://github.com/padrino/padrino-framework/blob/5fe35ccbd2ffbf78d78233e9a47759eff1c6cc92/padrino-core/lib/padrino-core/cli/base.rb#L16
Considering your desire to host development mode app on local Ethernet, you have a dedicated server and you should have no problem setting up something like Passenger to host your app.
BTW, version 1.5.2 of rack still hosts the config.ru on 0.0.0.0, if you are locked on this version you can use rackup to host your development app for local network.
I am running CentOS 6.4 through vagrant.
I have put this line inside my Vagrantfile:
config.vm.network :forwarded_port, guest: 80, host: 8080
Then I have installed nginx in the VM and verified it's working with:
wget http://locahost/
Works fine.
But from my host machine (Macbook Air, Mountain Lion) when I go to:
http://localhost:8080
It times out. Did I miss any configuration in Vagrantfile?
I have used this box:
https://github.com/NREL/vagrant-boxes
Have you checked your iptables?
It's a common mistake: when you use provisioning you also have to configure your iptables. (For puppet you have this module.) If you don't want to work with a firewall you can just do vagrant ssh followed by sudo service iptables stop.
What do you see when you go to your browser? Does it say Data not received or it never stops reloading? Do you get any messages in your browser? The server config file must be a bit messed up. Try reloading the server configuration, and restarting it.
Also, try changing the port number to something else. With the newer version of Vagrant, the syntex looks a bit different. So you have to do:
config.vm.forward_port 80, 2759
This is the config file that I use for one of my instances:
Vagrant::Config.run do |config|
config.vm.box = 'rails-dev-ready'
config.vm.host_name = 'rails-dev-ready'
config.vm.forward_port 5800, 5800
config.vm.forward_port 1080, 1090
config.vm.forward_port 80, 2759
config.vm.provision :puppet,
:manifests_path => 'puppet/manifests',
:module_path => 'puppet/modules'
config.vm.share_folder "sharedapps", "/home/vagrant/sharedapps", "sharedapps"
end
I recently set up a CentOS 6.4 box. My ports got all messed up because of iptables. I just disabled the service. It's in /sbin/sevices.
You may run the following command to find out if any other process (such as Tomcat) is bind to port 8080:
lsof -i :8080
If so, that may cause the problem.
I have found a solution,
I have found that there is an issue with Apache + vagrant, and sometimes Apache won't start automatically.
Please try: sudo service apache2 start once logged in via ssh.
I was having issues with Vagrant and all the error messages indicated a networking problem, but in reality my Apache service just wasn't starting on vagrant up
I apologize for such a beginner question, but I'm stuck. I'm starting learn web development and I want to test out something I am hosting locally using Django runserver command. I would like to test it on my iPhone. According to this question, I just need to point my iPhone to my Windows 7 ip address (which I found through ipconfig). When I try to, I get the error: "Safari could not open the page because the server stopped responding" (a time-out).
Is there anything else that I need to do?
In addition to using the correct IP, your runserver command should listen on 0.0.0.0(all IPs).
runserver 0.0.0.0:8000
Below steps worked for me on MAC OS 10.10.3
python manage.py runserver 0.0.0.0:8000
in terminal window "ipconfig getifaddr en0" returned IP address 10.0.1.22
open browser in Iphone/Ipad "http://10.0.1.22:8000"
You need to use the IP address AND port that the runserver is running on... this is usually :8080 or whatever number that follows the IP it reports when it runs the server.
so if the runserver command reports...
http://127.0.0.1:8000/
then if your IP is 192.168.0.2 use...
http://192.168.0.2:8000/
If for some reason you want to set the port manually, runserver [port] works...