Как исправить ошибку java net socketexception

  • MiniTool

  • MiniTool News Center

  • Fix: Internet Exception java.net.SocketException Connection Reset

By Anna | Follow |
Last Updated May 31, 2023

google search

Some people meet this connection lost error – Internal Exception: java.net.SocketException: Connection Reset – in Minecraft. So what does that mean? To fix this error, this article on MiniTool Website has issued some available methods and you can refer to that.

Internal Exception java.net.SocketException Connection Reset

Have you ever seen this connection lost error in Minecraft – Internal Exception java.net.SocketException Connection Reset? It is an annoying issue interrupting your attention and destroy the gaming experience when you are playing Minecraft.

The reasons that trigger this error are complicated and varied but don’t panic, you can try some easy tips to see if this java.net.SocketExeption Connection error can be fixed.

  1. Check the Internet connection.
  2. Try using a VPN.
  3. Uninstall the Hamachi VPN if you are using it.

Related article: How to Use Hamachi for Minecraft? Check Answers from Here!

Fix the java.net.SocketException Connection Reset error

Fix 1: Change the DNS Server

The java.netsocketexeption error is probably made by the connection issue, so you can try to change the DNS sever and see if the issue can be resolved.

Step 1: Press the Win + S key to open the Search box and input control panel to open the result of Best match.

Step 2: Switch View by: to Small icons and choose Network and Sharing Center.

choose Network and Sharing Center

Step 3: Click on your Internet connection (Usually Ethernet) and choose Properties.

choose Properties

Step 4: In the next page, double-click on Internet Protocol Version 4 (CTP/IPv4) and check the options of Use the following IP address and Use the following DNS server addresses.

Step 5: Then input 8.8.8.8 for the box next to Preferred DNS server and 8.8.4.4 for the box next to Alternate DNS server.

input DNS server

Step 6: Check the box for Validate settings upon exit and choose OK to save your choice.

Fix 2: Renew Your System IP Address

To fix the java.net.SocketException Connection Reset error, another way is to release and renew your system IP address. Here is the way.

Step 1: Type cmd in Search and run Command Prompt as an administrator.

Step 2: When the Command Prompt window opens, you can enter the following commands and press Enter after every one of them.

  • ipconfig /release
  • ipconfig/flushdns
  • ipconfig/renew

When the command is finished, a new line appears at the bottom of the Command Prompt screen that contains an IP address. Then you can close the window and relaunch Minecraft to see if the issue is resolved.

Fix 3: Allow Minecraft though Windows Firewall

Your Windows Firewall may block Minecraft from running normally for its security consideration. You can try to disable Windows Firewall temporarily and see if the error message “Internal Exception: java.net.SocketException: Connection Reset” appears again.

Then you can add Minecraft to the white list so that Windows Firewall will allow Minecraft to run.

Step 1: Go to Start > Settings > Update & Security > Windows Security > Firewall & network protection.

Step 2: Then choose Allow an app through firewall and in another window, select Change settings and Allow another app….

Allow another app…

Step 3: Click Browse… to choose Minecraft EXE file and select Add to add it to the Firewall.

Bottom Line:

To fix the Internal Exception: java.net.SocketException: Connection Reset, the above methods will be helpful. Hope this article can resolve your issue.

About The Author

Anna

Position: Columnist

Anna is an editor of the MiniTool Team. She worked in this big family since her graduation. Her articles mainly focus on data backup and recovery, disk cloning, and file syncing, committed to resolving the data loss issues users may encounter on their PCs. Besides, more related computer articles are shared here. In her leisure time, she enjoys reading and watching movies. Travel can also be a good choice for her.

You should inspect full trace very carefully,

I’ve a server socket application and fixed a java.net.SocketException: Connection reset case.

In my case it happens while reading from a clientSocket Socket object which is closed its connection because of some reason. (Network lost,firewall or application crash or intended close)

Actually I was re-establishing connection when I got an error while reading from this Socket object.

Socket clientSocket = ServerSocket.accept();
is = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
int readed = is.read(); // WHERE ERROR STARTS !!!

The interesting thing is for my JAVA Socket if a client connects to my ServerSocket and close its connection without sending anything is.read() is being called repeatedly.It seems because of being in an infinite while loop for reading from this socket you try to read from a closed connection.
If you use something like below for read operation;

while(true)
{
  Receive();
}

Then you get a stackTrace something like below on and on

java.net.SocketException: Socket is closed
    at java.net.ServerSocket.accept(ServerSocket.java:494)

What I did is just closing ServerSocket and renewing my connection and waiting for further incoming client connections

String Receive() throws Exception
{
try {                   
            int readed = is.read();
           ....
}catch(Exception e)
{
        tryReConnect();
        logit(); //etc
}


//...
}

This reestablises my connection for unknown client socket losts

private void tryReConnect()
        {
            try
            {
                ServerSocket.close();
                //empty my old lost connection and let it get by garbage col. immediately 
                clientSocket=null;
                System.gc();
                //Wait a new client Socket connection and address this to my local variable
                clientSocket= ServerSocket.accept(); // Waiting for another Connection
                System.out.println("Connection established...");
            }catch (Exception e) {
                String message="ReConnect not successful "+e.getMessage();
                logit();//etc...
            }
        }

I couldn’t find another way because as you see from below image you can’t understand whether connection is lost or not without a try and catch ,because everything seems right . I got this snapshot while I was getting Connection reset continuously.

enter image description here

A SocketException Connection reset is one of the most common Runtime errors you can find in Java applications. As the name implies, it happens during a network connection which terminates abruptly. In this tutorial we will teach you which is the best action plan to find the root cause of the issue.

What is a “Connection reset” and which are the possible causes?

“Connection reset” simply means that you received a TCP RST. This occurs when your peer receives data that it can’t process, and there can be various reasons for this. The simplest one is when you close the socket and then write more data on the output stream. Then, when you send more data on that stream anyway, the peer rejects it with an RST to let you know it isn’t listening.

How to solve the error java.net.SocketException: Connection reset

A slightly different case is “java.net.SocketException: Connection reset by peer”. This error hints that the remote host sent the connection reset (i.e., the host that the Java application is connecting to).

There are several possible causes for this error, such as:

Firewall

Firstly, if the firewall has a rule that blocks all incoming traffic from the client, it may send an RST packet to the server to reset the connection as soon as it receives a SYN packet from the client.

Also, if the firewall has a rule that allows incoming traffic from the client, but blocks all outgoing traffic from the server to the client, it may send an RST packet to the client to reset the connection when it receives a SYN-ACK packet from the server.

Then, if the firewall has a rule that allows incoming traffic from the client, but blocks all outgoing traffic from the server to the client based on the port number or protocol, it may send an RST packet to the client to reset the connection when it receives a SYN-ACK packet from the server.

Finally, if the firewall has a rule that allows incoming traffic from the client, but blocks all outgoing traffic from the server to the client based on the content of the packets, it may send an RST packet to the client to reset the connection when it receives a SYN-ACK packet from the server that contains data that matches the specified criteria.

Network Scanner

A network scanner can cause a TCP connection RESET between a client and a server by sending a forged RST packet to one or both of the devices.

For example, a network scanner could send a forged RST packet to the client, pretending to be the server. The client would receive the RST packet and believe that the server wants to reset the connection. So it would send an RST packet back to the server and close the connection.

Alternatively, the network scanner could send a forged RST packet to the server, pretending to be the client. The server would receive the RST packet and believe that the client wants to reset the connection, so it would send an RST packet back to the client and close the connection.

In either case, the network scanner could use this technique to disrupt the communication between the client and the server.

Network switch

A network switch can cause a TCP connection RESET between a client and a server when the connection is idle if the switch has a feature called “TCP idle timeout” enabled. This feature allows the switch to close idle TCP connections after a certain period of inactivity. This will result in a premature termination of the connection between the client and the server at the network layer.

Databases

In some cases, the database server may be terminating the connection. This can be due, for example, to a configuration (e.g. timeout period) of the Database server. It can also be related to a defect in the Database driver.

You can manage most of database timeouts/stale connection issues with a proper configuration of Datasource validation. Learn more here: How to validate Database connections in JBoss / WildFly

Client application

Finally, there can be an issue with the Java Client application connecting to the server. A common case is a bug in the software. But it can be as well a misconfiguration or something in the Client OS settings

Finding the root cause

After discussing all possible causes of a “java.net.SocketException: Connection reset”, let’s see how to find the root cause. If your server logs/system log do not provide any extra clue, the best option is to start a dump session.

Here are some things to look for in a dump session:

  • If the client is initiating the disconnect, it will typically send a FIN packet to the server to close the connection. You can use tcpdump or a similar tool to capture and inspect the packets being sent over the network.
  • If the server is initiating the disconnect, it will typically send a RST packet in response to a client request, or close the connection after a period of inactivity. You can use tcpdump or a similar tool to capture and inspect the packets being sent over the network.

For example, Linux users can start the tcpdump command:

 tcpdump -i eth0  port 8080  and '(tcp-syn|tcp-rst)!=0' 

The above tcpdump command will list SYN (connection attempts) and RST (reset connections) on port 8080. Let’s see a practical example:

$ netstat -na

Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 127.0.0.1:8080          0.0.0.0:*               LISTEN

$ tcpdump -i eth0  port 8080  and '(tcp-syn|tcp-rst)!=0' 

tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
20:34:50.569441 IP localhost.8080 > localhost.41300: Flags [S], seq 1779073596, win 65535, options [mss 65495,sackOK,TS val 838312 ecr 0,nop,wscale 7], length 0
20:34:50.569474 IP localhost.41300 > localhost.8080: Flags [R], seq 0, win 0, length 0

This dump shows that the client is sending a SYN packet to initiate the connection. Then, the server is sending a RST packet to reset the connection. For example, it could be a firewall blocking the connection. You can use tools such as iptables or ufw to view and configure the firewall rules on the system.

Conclusion

This article was a walk through the analysis of the Connection reset error in a Java applicaion. In most cases, to further understand the cause of the error, you can try examining other packets being exchanged between the client and server, and analyzing the system activity.

The Minecraft internal exception java.net.socketexception connection reset error is a common issue many users face in Minecraft nowadays. The same error appears in Minecraft version 1.7 and later.

When this error prompt appears on the screen, users are disconnected from the server and refrain from playing the game.

There can be many causes for the same issue, and there are many solutions also available. The same error affects Minecraft Realms and even in multiplayer servers as well.

If you are also suffering from the same issue, then you can depend on this article to get rid of the issue easily.

Then let’s have a look.

How to fix internal exception java.net.socketexception connection reset in Minecraft

Fix 1: Restart the Game

Sometimes restarting the game can help you solve the same problem quickly and effectively.

Log out of Minecraft and log into the game after a few minutes to see the result.

Fix 2: Change DNS Server

As an effective trick to resolve the Internal Exception: java.net.SocketException: Connection Reset Issue in Minecraft is changing the DNS server.

To do so, 

  • Firstly, click on the Open Network and Internet settings from your desktop bottom right corner.

2022 01 24 11 01 54 Settings

  • In the newly opened window, click on the Network and Sharing Center option from the left pane menu.
  • On the next window, click on your Network connection and select the Properties option.
  • Inside the Properties window, double click on Internet Protocol Version 4 (TCP/IPv4).
  • Then click the radio button beside the Use the following DNS server addresses.
  • 2022 01 24 11 03 03 Internet Protocol Version 6 TCP IPv6 Properties
  • Now set the Preferred DNS server as 8.8.8.8 and the Alternative DNS server as 8.8.4.4
  • Finally, tick beside the Validate settings upon exit check box, save the changes and see the result.

Fix 3: Use a VPN

Another solution to tackle the Internal Exception: java.net.SocketException: Connection Reset Issue in Minecraft is using best paid VPN services. Using a reliable VPN service helps you to change the IP address. In addition, select a VPN that uses multiple server addresses. Several VPN services are available there, such as ExpressVPN, NordVPN, ProtonVPN, CyberGhost, and many more.

Fix 4: Check Internet Connection

Sometimes the Java. Error can occur in Minecraft due to poor internet connection. In this scenario, you need to check your internet connection accuracy and Wi-Fi router performance and ensure everything is perfect. If there is any issue with the Wi-Fi router, then you can switch to a wired connection or contact your internet service provider.

Fix 5: Renew System IP Address

Few suffered users claimed in the Social platform that they finally escaped from the Internal Exception: java.net.SocketException: Connection Reset Issue in Minecraft by renewing the IP address. You can apply the same procedure in your case as well. To do so, 

  • Firstly, type cmd in your search box and open the Command Prompt window as Administrator.
  • 2022 01 24 11 06 16 Greenshot
  • Then copy+ paste or type the following command in the Command Prompt window and press Enter and each commands,

ipconfig/release

ipconfig/flushdns

ipconfig/renew

  • Once you execute all these commands, close the window, relaunch Minecraft and run the game to check improvement.

Fix 6: Reduce Render Distance:

Last but not least solution to fix the Internal Exception: java.net.SocketException: Connection Reset Issue in Minecraft is reducing the Render distance. To do so,

  • Firstly, launch Minecraft, and you need to join the single-player map.
  • Then click on the Esc key on your keyboard and select the Options.2022 01 24 11 08 51 1Im5MWxfBxJuQp1p0gC vr5wtubAC0IshaXkdVuR1tM.jpg 1920×1080
  • And select Video Settings, then Reduce the Render distance to 8 or lower
  • Further, set the Graphics option to Fast and disable the Smooth lighting option.
  • Finally, relaunch Minecraft and check the error disappeared or not.

So these are the possible solutions for the Internal Exception: java.net.SocketException: Connection Reset Issue in Minecraft. Along with all these fixes, you can also uninstall Hamachi and see it helps you or not. However, if you have any queries or doubts after reading this article, then please leave a comment in the below-given comment box.

FAQ — Minecraft Internal Exception java.net.socketException Connection Reset

  • This error usually occurs as a result of the server connection being closed. You can check if the server has failed over to a different host.

  • You can simply resolve the Minecraft connection lost internal exception issue by using a reliable VPN service. A VPN service provides a different IP address that can bypass server connection issues.

  • The internal exception Java net SocketException connection reset means it’s a server side issue. When the client closes the socket connection before the response can be returned on the socket.

  • The main reason behind internal exception java.net.socketexception connection reset issue can be slow or bad network connection. Using a good VPN service can help you avoid the same problem.

  • The “Internal Exception: java.net.SocketException: Connection reset” error can seem like a simple internet connectivity issue at first glance, but it’s much more than that. This error has been around for years and doesn’t have a single fixed cause.

    Accordingly, users have managed to resolve it with various unlikely methods, like creating a new installation profile or adjusting the graphic settings. Others have placed the blame on server-side issues, although the devs continue to deny this.

    Leaving that controversy aside, the important detail is that even though there’s no official patch from the devs, there are time-tested solutions that have helped numerous users. We’ve compiled a list of such fixes in this article.

    Before anything, restart your PC and router. Once that’s done, run Minecraft as an administrator. If the error persists, move on to the solutions to start troubleshooting.

    VPN-related Fixes

    disable vpn connecting

    We’ve found this error to be primarily related to VPNs, both in good and bad ways. Some users reported that this error didn’t occur when connected to a VPN. Others found that a VPN didn’t help at first, but after trying a few different clients and server locations, the error no longer occurred.

    On the other hand, some users first encountered this error when playing with a VPN. In such cases, it would be best to disable the VPN instead. 

    Specifically, after limited testing, the Minecraft Community Support Discord members found Hamachi VPN to be one of the main causes of this error. If you’re using Hamachi VPN as well, we recommend uninstalling Hamachi, or atleast disabling it, and checking if the error is resolved.

    Check Network Configurations

    The reason VPNs have resolved this issue for so many users has to do with your IP address on the current network. As such, simply connecting to a different network could be all that’s needed to fix this error.

    Configuring a couple of global TCP settings has also been one of the most successful fixes for this error. Here’s how you can apply this fix:

    1. Press Win + R, type cmd, and press CTRL + Shift + Enter.
    2. Type netsh interface tcp show global and press Enter.
      netsh-interface-tcp-show-global
    3. Check the value of Receive-Side Scaling State. If it’s disabled, type netsh interface tcp set global rss=enabled and press enter.
    4. Next, check the value of Receive Window Auto-Tuning Level. If it’s disabled, type netsh interface tcp set global autotuninglevel=normal and press enter.
      netsh-interface-tcp-set-global-autotuninglevel-normal
    5. Exit command prompt, launch Minecraft, and check if the error is resolved.

    If the error persists, we recommend manually changing the DNS server as the next step. If that doesn’t help either, execute the commands listed below in command prompt. They’ll perform a bunch of useful actions, including clearing your DNS cache and renewing your IP.

    Java-related Fixes

    The official Minecraft launcher handles Java installation for Minecraft automatically, so generally, it’s not something the player needs to worry about. But when running dedicated servers on older Java versions, it is essential.

    First, you’ll want to download and install the JDK. Some users have had success with the latest version, while others had to install older versions like JDK16 to resolve the error. So essentially, it’s worth trying out different versions.

    Next, you’ll also want to ensure JDK is allowed through the firewall. If you’re using any third-party firewall, we recommend temporarily disabling it to check if the error gets fixed. In the case of Windows Firewall, here are the steps you should follow:

    1. Press Win + R, type control firewall.cpl, and press Enter.
    2. Click on Allow an app or feature through Windows Defender Firewall.
      allow-an-app-or-feature-through-firewall
    3. Click on Change settings and accept any prompts.
      change-firewall-settings
    4. Scroll down and select OpenJDK Platform Binary. Ensure the checkboxes in both the Private and Public fields are enabled.
    5. If you don’t find this entry, click on Allow another app > Browse.
      allow-another-app-firewall
    6. Select javaw.exe and select Open > Add from the following location:
      C:Program Files (x86)Minecraftruntimejava-runtime-alphawindows-x64java-runtime-alphabin
    7. Finally, press OK, launch Minecraft, and check if you still get the error.

    Migrate to Microsoft Account

    Some users found that the error stopped occurring after they migrated their Mojang accounts to Microsoft. The Minecraft Help Center has extensive guides that answer most of the common queries regarding the migration process, so we highly recommend referring to said guides if you need help with the migration.

    Workaround with Epic Games Launcher

    If you start downloading any random game in the Epic Games Launcher and then try to launch Minecraft, chances are, you won’t encounter the error. There’s no sound reasoning for why this workaround works, but the important part is that it did let countless users play without the error, so it’s worth trying.

    Create New Launcher Profile

    This is another solution recommended by Mojang, with a proven record. Here’s how you can use a new installation profile:

    1. Run the Minecraft launcher and click on Installations.
      minecraft-java-edition-launcher
    2. Click on New Installation and name it as you please.
    3. Set the version to an older one (e.g., 1.18.2 ) and try launching Minecraft.

    Check Visual Settings

    Downgrading the game graphics has resolved this error for numerous players. Even teleporting to an unmodified area has been helpful in some cases. This is possibly because the server is unable to handle how fast you’re loading the world at your current settings. Here’s what we recommend:

    1. In Minecraft, enter a different world if necessary and go to Options > Video Settings.
      minecraft-options-video-settings
    2. First, turn off Full screen and try lowering the resolution.
      minecraft-full-screen-toggle
    3. Restart Minecraft and check if the error is resolved.
    4. Reduce the Render Distance to 12 chunks or lower, then restart and check again. Additionally, toning down the Graphics and Simulation distance settings can help with lag.
      minecraft-render-distance
    5. Finally, one user also found that uninstalling all the texture packs fixed the problem. So, if the error still persists, this may be worth trying.

    Server-related Fixes

    There are a number of server-related solutions useful for resolving this error. We recommend trying them in the following order:

    • First, increase the server memory. The default amount (1GB) is known to cause connection issues and crashes as the limit is easily reached.
    • Try switching to a lower server version.
    • If you’re the host, you could try copying the private server files to another location. If you encounter problems moving any files, said files could be the cause of the error.
    • Additionally, starting a new world with a new server host could also help.

    Reinstall Minecraft

    If the error still persists, uninstalling and reinstalling Minecraft is likely the final option at this point. You’ll want to copy the saves from the .minecraft folder in %appdata% before uninstalling, though. Additionally, a PC reset is overkill for this error, but if you’ve backed up your files elsewhere and playing Minecraft means a lot to you, then this is an option to consider as well.

    Понравилась статья? Поделить с друзьями:
  • Как исправить ошибку microsoft visual c 2015 runtime
  • Как исправить ошибку iw4sp exe
  • Как исправить ошибку microsoft teredo
  • Как исправить ошибку isdone dll код ошибки 11
  • Как исправить ошибку microsoft teredo