Answer the question
In order to leave comments, you need to log in
Why is the socket not connecting on a real device?
running on emulator
Socket socket = new Socket("10.0.2.2", portNumber);
and everything works fine java.net.ConnectException: failed to connect to /127.0.0.1 (port 5000) from /:: (port 33717): connect failed: ECONNREFUSED (Connection refused)
Answer the question
In order to leave comments, you need to log in
127.0.0.1 is a request to itself (the phone calls itself)
10.0.2.2 is a request to the local network.
Show what the request for 10.0.2.2 says
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question