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...
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
As pythonanywhere is the one of best place to host python web app. And apps will be hosted as per wsgi.py configurations on it's own server. But what happens when I do something like this on its bash shell?
$ python manage.py runserver 127.0.0.1:9000
Performing system checks...
System check identified no issues (0 silenced).
April 28, 2016 - 15:29:48
Django version 1.9.5, using settings 'MyProject.settings'
Starting development server at http://127.0.0.1:9000/
Quit the server with CONTROL-C.
As you can see I had changed the port to :9000, so is there any way to access this or it's just meaningless as it's serving the app on served server service?
PythonAnywhere dev here. There's no way to access a server you run using manage.py runserver. It will try to bind to a local port, but that port isn't visible from outside the PythonAnywhere cluster.
[edit] Oh, and thank you for the kind words about PythonAnywhere!
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
I have developed a simple application in Eclipse & Django & Pydev. The application fails while starting and I am given the following error:
*Error: [Errno 10013] An attempt was made to access a socket in a way forbidden by its access permissions*
I have tried changing the port number to 8080 in Eclipse by changing the Run Configurations, but this has failed.
How can solve this problem and host my Django application on other port?
If you are willing to do this outside of Eclipse, you can run the Django development server on a different port with
python manage.py runserver PORT_HERE
For example, to use port 8005, you can do
python manage.py runserver 8005
I want to remote debug the nodejs program in Eclipse. I start the node script with the debug option.
$node debug script.js
But I can't connect to the node in Eclispe. When I netstat the node's TCP port. I found that node only listen 127.0.0.1 in debug mode. So I can't connect it from different computer.
But I can't find any startup options that can change to listen to any address.
Anyone know to make it listen to any address to remote debug in other computer?
if anyone else stumble upon this: you can set the node debug to any address as you set the port
node --debug=169.168.1.2:5858 app.js
if that would be the ip of your remote machine or even better to every machine
node --debug=0.0.0.0:5858 app.js
but please be aware that the 2nd option should only be used if you are debugging in your own private network as you open it up for everyone
This is what I do in linux Debian:
install balancer
sudo apt-get install balance -y
then create a route in balancer to reroute your 5858 port to 5859
balance 5859 127.0.0.1:5858
start your app
node --debug app.js
now you can access it from everywhere on port 5859
I'm looking into V8 code that goes through deps/v8/src/debug-agent.* down to deps/v8/src/platform-posix.cpp (for linux) to POSIXSocket::Bind method and it can't seem to have any option about this (unless I'm missing something).
I bet you either hack it and recompile node or you'll need to build a small proxy beside your node process.
Here's a great tut on debugging nodejs from eclipse. Note at the bottom there is a script the author uses to forward localhost:5858 to the remote server's 127.0.0.1. You could also just use an SSH tunnel.
So, to summarize:
start your script with node --debug app.js
configure eclipse as if you were debugging locally
use the node_g script or configure an SSH tunnel
go on vacation now that your code is bug-free
to debug nodejs remotely over SSH session do:
1. install balance on Linux: https://balance.inlab.net/overview/
2. run the command: balance -df 8585 127.0.0.1:5858 > /tmp/balance.out 2>&1 &
3. ssh to your remote Linux box (tunnel will be created 8585 > 5858 > nodejs)
4. run your node script on server: node --debug-brk --nolazy ./myNodeApp.js
5. kick off debug session in WebStorm alt-d to port 8585
now you are remote debugging securely over SSH session