. Advertisement .
. Advertisement .
Python is an easy-to-learn programming language that quickly becomes one of the best beginning programming languages for beginners.
When we attempt to do our tasks by using the program, we may receive the following error message: “java.net.SocketException: socket failed: EPERM (Operation not permitted)“.
This is a common error that every developer makes. So, what causes it, and how does it get resolved? We’ll talk about it with you.
Why Does The Error “java.net.SocketException: socket failed: EPERM (Operation not permitted)” Occur?
You are trying to run your project on the emulator, facing the following error.
java.net.SocketException: socket failed: EPERM (Operation not permitted) at java.net.Socket.createImpl(Socket.java:492) at java.net.Socket.getImpl(Socket.java:552)
What causes error?
Note that, when you use this command: android:usesCleartextTraffic, you must make sure the current API version is 2.3 or higher. So if yours are lower, this could be the cause of your error. In addition, another cause is because there is a conflict when accessing.
How to fix it?
And, guess what, you might be able to solve it with some simple approaches. We will better understand the previous answers by using the examples below.
Solution 1: Add the permission in your android manifest
Add the permissions INTERNET and ACCESS NETWORK STATE to your android manifest xml file.
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Next, you need to uninstall and then reinstall the application on your device, and your problem should be resolved.
Solution 2: Reinstall the app on your device
You need to remove the app from your Emulator OR Physical Device. Then you would install the app again on your device. And your mistake must now be corrected.
Solution 3: For Mac users
If you’re running a localhost domain controller on your Mac, the API address should be the machine’s local Internet protocol. Specifically, 192.168.x.x (located in Settings -> Network) rather than localhost or 127.0.0.1.
As previously stated, uninstall the software and include the following tags in the manifest. In the section for applications, you use this line.
In general, the best solutions provided above are the most practical for those still perplexed by this error: “java.net.SocketException: socket failed: EPERM (Operation not permitted)“.
If you still need help or have frequent Node.js questions, we have a very active community where everyone is always willing to help. Finally, we wish you a fantastic day filled with new code solutions.