NanoHttpd / nanohttpd

Tiny, easily embeddable HTTP server in Java.
http://nanohttpd.org
BSD 3-Clause "New" or "Revised" License
6.9k stars 1.69k forks source link

Can't access the webpage on my laptop connected to my android server through mobile hotspot #556

Closed Haider8 closed 4 years ago

Haider8 commented 4 years ago

I have created the android server on my mobile phone and on the same phone I have opened my hotspot. Upon connecting my laptop to my mobile hotspot I can't access that webpage by my mobile's ip address. Please help me how I can do that?

Note: Right now I can only access the webpage on my mobile's localhost.

simple565 commented 4 years ago

I have the same problem,have you fixed it?

AndreasGabel commented 4 years ago

Same here, with SimpleWebServer implementation only localhost seems to work, but no access through IP address (e.g. in browser), even on the same device. ERR_CONNECTION_REFUSED error is shown in browser and says "[IP address] refused to connect.". Is this a result of having no CORS settings set (cors = null) or should it work anyway?

Edit: cors set to "http://192.168.43.151" (host device ip address) does not make a difference.

Haider8 commented 4 years ago

Try setting your server on 0.0.0.0 rather then localhost in your code and check carefully that you enter your mobile's private ip in your browser. This worked for me.

On Thu, Sep 12, 2019, 10:18 AM AndreasGabel notifications@github.com wrote:

Same here, with SimpleWebServer implementation only localhost seems to work, but no access through IP address (e.g. in browser), even on the same device. ERR_CONNECTION_REFUSED error is shown in browser and says "[IP address] refused to connect.". Is this a result of having no CORS settings set (cors = null) or should it work anyway?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/NanoHttpd/nanohttpd/issues/556?email_source=notifications&email_token=AKKLEUEEPO4IPFCAAN3VMD3QJHCYVA5CNFSM4ISQOWWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6QUOLY#issuecomment-530663215, or mute the thread https://github.com/notifications/unsubscribe-auth/AKKLEUHL2Q7XU6FTMHZAMATQJHCYVANCNFSM4ISQOWWA .

AndreasGabel commented 4 years ago

You are right, I just figured it out as well: setting 0.0.0.0 or null as hostname works fine. Thank you anyway.