I have a django server running on my PC. I want to access the server through my android phone.How can I do that? I tried running
python manage.py runserver 0.0.0.0:8000.
After this, I can access server from my pc through PC's ip address, but not accessible through other device coonected to same wifi.
you need to do these steps
1. run python manage.py runserver 0.0.0.0:8000
2. figure out your ip address which is say 192.168.1.8
3. Add '192.168.1.8' to ALLOWED_HOSTS list in your settings.py file.
4. access 192.168.1.8:8000 on mobile.
I tried this, its working for me.
can you try it python manage.py runserver youripadress:8000 [python manage.py runserver 192.168.0.1:8000]
In your terminal run
ipconfig
and find the IPv4 address
,and if you are using Django go to settings.py and in the ALLOWED_HOST add the IPv4 address in the list.
In my case
ALLOWED_HOSTS = ['192.168.30.81', '127.0.0.1', '0.0.0.0', '192.168.167.206']
then run ( in my case )
python manage.py runserver 192.168.167.206:8000
A related issue I ran into was in relation to this error:
"code 400, message Bad HTTP/0.9 request type ('\***\***\***\***\***\***\***\***\***')
[time stamp] You're accessing the development server over HTTPS, but it only supports HTTP"
Just verify that this is the reason you are not able to view also. Of course you would see this in your server messages if so.
Related
I try to use SSH on Android the first time, i had read a lot about it but i cant find much, only from Android to Computer. Maybe someone can help me here:)
I have coded an APK for my own Android Device wheres create an SSH Connection over my PHP Script using Proxy Server.
I use an Debian VPS as Proxy Server. With this IP, the Android creates an Proxy.
Now i use this Comment:
ssh -N -L 34836:127.0.0.1:34836 newgenerateduser#23.106.XXX.XX
Port is generated also random every time i create an new proxy over PHP Script.
I use now an Virtual Machine with Ubuntu and enter the Comment in my Terminal with the Passwort after asking.
I start my VNC Client and want get remote Control over my Android device using VNC or SSH with this IP and Port:
127.0.0.1:34836
I got this Message:
lxs#linux-virtual-machine:~$ ssh -N -L 34836:127.0.0.1:34836 newgenerateduser#23.106.XXX.XX
newgenerateduser#23.106.XXX.XX's password:
channel 2: open failed: connect failed: Connection refused
I also tried using localhost instead of IP.
There are special requirements for the Proxy Server? Or just Port blocking on it?
Thanks for your help!
I'm attempting to test my local dockerised API against a staging version of my app.
I don't have access to the repository to build the App myself so I'm relying on changing the IP address within the emulator to point at my local machine and that's where I'm failing.
I've set it to 10.0.2.2 as per the emulator documentation, and when I ping the staging url from the ADB shell (ping mystagingsite.com) it responds data from 10.0.2.2 . But from within the app, the response is always empty. I've tried 127.0.0.1 which obviously won't work, and I've tried my network IP address.
Is what I'm trying to do possible? If it is, what is the right IP address to put in the /etc/hosts file of the emulator and how do I find that address?
So I did a research before posting this and the solutions I found didn't work, more precisely:
-Connecting to my laptop's IPv4 192.168.XXX.XXX - didn't work
-Conecting to 10.0.2.2 (plus the port) - didn't work
I need to test an API i built using Django Rest framework so I can get the json it returns, but i cant access through an Android app i'm building (I'm testing with a real device, not an emulator). Internet permissions are set on Manifest and i can access remote websites normally. Just can't reach my laptop's localhost(they are in the same network)
I'm pretty new to Android and Python and Django as well (used to built Django's Rest Framework API).
EDIT: I use localhost:8000/snippets.json or smth like this to connect on my laptop.
PS: I read something about XAMP server... do I need it in this case?
Thanks in advance
Have you started the server like this?
python manage.py runserver 0.0.0.0:8000
Then, try to connect to 192.168.XXX.XXX:8000
I tried the above, but failed to work in my case. Then with running
python manage.py runserver 0.0.0.0:8000 I also had to add my IP to ALLOWED_HOSTS in settings.py, which solved this issue.
eg.
Add your ip to allowed hosts in settings.py
ALLOWED_HOSTS = ['192.168.XXX.XXX']
Then run the server
python manage.py runserver 0.0.0.0:8000
Others have already given the answer but those solutions didn't work for me when I was running Django server on Ubuntu and was trying to access it from my Mobile app.
Following is what worked for me:
Step 1: Run server to access it from your IP
python manage.py runserver 0.0.0.0:8000
Step 2: Open port in firewall (Missing step in above given answers - Needed for Ubuntu)
$ sudo ufw enable
$ sudo ufw allow 8000
here is any configuration for this tools eclipse or wamp or android sdk to connect my mobile phone to wampserver?
i look this exemple in this site blow i just copy and paste the code in eclipse but the problem is how i can import and export data from my phone to database and Conversely ?
http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/
If I've understood correctly, you're running a wamp server locally on your computer and you'd like to access that server from your application. The general approach is similar to connecting to any other server, but you'd have to find the right IP-address to connect to. Try this:
First, make sure your server is up and running.
Second, access the server on your computer using one of two addresses:
If you're testing your app on the emulator (AVD), use this: 10.0.2.2, which translates to the localhost-address on your computer.
If you're testing your app on an actual device, you'd have to find your computer's IP-address. On linux, open a terminal and execute the command ifconfig. In windows, I believe it's ipconfig. Use the address listed under wlan0 -> inet addr.
Remember to append the port number your server is running on.
EDIT
Example, given port number is 80:
Emulator: 10.0.2.2:80
Device: 192.168.X.X:80
I'm trying to use an Android emulator to use services running on my local machine. I have a site running under IIS which in my host file looks like this:
127.0.0.1 www.local.company.co.uk
I have several sites running under Apache Tomcat. My host file for Tomcat related sites:
127.0.0.1 internal.localhost.company.com # port:8090
127.0.0.2 external.localhost.company.com # port:8081
127.0.0.3 auth.ws.localhost.company.com # port:8082
127.0.0.8 mysite.localhost.company.com # port:8086
What I have tried so far (in the following steps):
adb pull /etc/hosts
Edit Android host file:
127.0.0.1 localhost
10.0.2.2 myefc.localhost.efinancialcareers.com
adb remount
adb push hosts /etc/hosts
Then I try to visit myefc.localhost.efinancialcareers.com in the browser and am told webpage not found. I’d at least expect it to go to www.local.company.co.uk.
What I would ideally like is to be able to go to any site on my local machine which are specified in the above host file examples.
I am on Windows 7 and using Tomcat 6. The emulator I am using is nexus one.
You need to use the IP address of your server. If you reference localhost from the device it will try to make a connection to itself through the loopback IP address 127.0.0.1.