How to access a local server from an Android device

Asked

Viewed 2,304 times

1

I have a server in Django running on my computer "localhost:8000/posts", and I am creating an Android client to access it.

Debugging my application on a real device, I tried to access by my Ipv4 knowing that both the computer and the cell phone are in the same subnet "192.168.X. X:8000/posts", However I can not access this link by mobile browser.

I checked the "Chrome://Inspect/" option in Google Chrome, but I don’t know how this can help me or if it can help me.

However, someone knows that it is the best alternative to establish this connection by both my App and browser?

  • Added <uses-permission android:name="android.permission.INTERNET"/> to Androidmanifest.xml ?

  • You are trying to access via WI-FI?

  • Reginaldo, Yes the 2 are connected to the same WI-FI network.

  • I put the INTERNET Permission, but the problem is beyond the application itself, since I can not access my server by the mobile browser itself

  • You can access the service using the browser of another machine on your network?

  • Neither from another nor from the computer itself, it just keeps charging

  • And you can stop and start the service in the Control Panel?

Show 2 more comments

1 answer

1

I found out what was happening, I was only able to access through the host "localhost:8000" or "127.0.0.1:8000" because the Django server was only accepting local access, since I was amazed only with the command

python manage.py runserver

So when I started the server with the command

python manage.py runserver 0.0.0.0:8000

The same returned to accept connections by my ip "129.169.x. x:8000"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.