1

I write my web services in Django, everything is OK when I test my API in postman (on http://127.0.0.1:8000/). But when I try to use Retrofit to connect http://192.168.43.115:8000 I cannot. This is the error:

message:java.net.ConnectException: failed to connect to /192.168.43.115 (port 8000) from /192.168.232.2 (port 50628) after 10000ms: isConnected failed: ECONNREFUSED (Connection refused

4
  • The 127.0.0.1:8000 in the output of lsof means that your program is listening only on the 127.0.0.1 interface, not on 192.168.43.255.
    – PerlDuck
    Jun 4, 2019 at 9:29
  • I cannot use 127.0.0.1:8000. failed to connect... Jun 5, 2019 at 8:07
  • Yes. You must make your application listen on all interfaces, not just on 127.0.0.1.
    – PerlDuck
    Jun 5, 2019 at 8:25
  • could you please explain more? How can I do that? Jun 5, 2019 at 10:11

2 Answers 2

2

I found the solution. I use ipv6 with this command:

python manage.py runserver [::]:8000    
0

I had the same problem with my Node.js API. the The solution was to stop the firewall service by running:

systemctl stop firewalld

(Note I'm using Fedora 30.)

That way I can access my Rest API in localhost via an Android phone.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .