I have attempted to set up a simple web server on Android using the nanohttpd demo application without modification. The Android devices that I am using are running Android 4.0.3.
I am able to access the web server from other devices, but I am unable to connect to the web server from a browser (Firefox, Chrome, and the native Android browser) on the same Android device that the web server is running.
I have tried a variety of addresses and port combinations without success (localhost, 127.0.0.1, 10.0.0.2, the actual assigned IP address, port 8080, 8082). I have also tried having the nanohttpd application bind directly to 127.0.0.1, without success either. I have verified that I can ‘ping’ the addresses using a terminal application on the Android device, so it looks like the network connectivity is fine.
Is there a restriction on Android that will prevent a browser from connecting to the local web server instance, and if so, is there a configuration setting or permission that needs to be modified to allow this to work?