Minecraft server list displays "Can't connect to server" on startup
The bug
Whenever I start my game and go onto the Multiplayer server list, the servers all say "Can't connect to server" but when I refresh the page, it says the normal servers MOTD in the listing.
Code analysis (MCP names), comments, and additional note by Kyle Repinski
I've analyzed the issue and found it's a race condition with the multi-threaded server pinger code. The server pinging code (net.minecraft.client.network.ServerPinger) is run in multiple threads, and each thread calls net.minecraft.network.NetworkManager.createNetworkManagerAndConnect(). This function uses "lazy loaders" (net.minecraft.util.LazyLoadBase) to initialize some static variables. The issue lies in net.minecraft.util.LazyLoadBase.getValue(). This function is not thread-safe. Below you'll find the code in question with comments explaining exactly what is happening and how to fix it.
package net.minecraft.util; public abstract class LazyLoadBase<T> { private T value; private boolean isLoaded; public T getValue() // NOT THREAD-SAFE. SIMPLE FIX: declare the method synchronized { if (!this.isLoaded) // Thread 1: Condition is true; Thread 2: Condition is false { this.isLoaded = true; // Thread 1: SETS isLoaded to true, BUT VALUE IS STILL NULL this.value = this.load(); } return this.value; // Thread 2: RETURNS NULL because this.load() is not finished in Thread 1 } protected abstract T load(); }
Note that depending on the speed of the computer, this bug might not occur. If the first thread finishes quickly enough everything will appear normal.
Linked Issues
is duplicated by5
Created Issue:
Minecraft server list start up...
Hi there, I have noticed that when ever I start my game and go onto the Multiplayer server list, the servers all say Cannot connect but when I refresh the page, it says the normal servers MOTD in the listing...
I dont know if this is just with my minecraft...
Environment
Multiplayer listing
Multiplayer screen after first starting the game. These servers are online and clicking on "Refresh" makes them show up again.
Multiplayer listing
is duplicated by
Minecraft server list startup...Minecraft server list displays "offline" on startup
is duplicated by
Hi there, I have noticed that when ever I start my game and go onto the Multiplayer server list, the servers all say Can
not connect but when I refresh the page, it says the normal servers MOTD in the listing...I dont know if this is just with my minecraft...
Hi there, I have noticed that when ever I start my game and go onto the Multiplayer server list, the servers all say "Can't connect to server" but when I refresh the page, it says the normal servers MOTD in the listing...
I dont know if this is just with my minecraft...
Hi there,I have noticed that whenever I start my game and go onto the Multiplayer server list, the servers all say "Can't connect to server" but when I refresh the page, it says the normal servers MOTD in the listing...I dont know if this is just with my minecraft...
is duplicated by
is duplicated by
MC-118749
I have noticed that whenever I start my game and go onto the Multiplayer server list, the servers all say "Can't connect to server" but when I refresh the page, it says the normal servers MOTD in the listing...
Minecraft server list displays "offline" on startupMinecraft server list displays "Can't connect to server" on startup
is duplicated by
The bug
Whenever I start my game and go onto the Multiplayer server list, the servers all say "Can't connect to server" but when I refresh the page, it says the normal servers MOTD in the listing.
Code analysis, comments, and additional note by Kyle Repinski
I've analyzed the issue and found it's a race condition with the multi-threaded server pinger code. The server pinging code (net.minecraft.client.network.ServerPinger) is run in multiple threads, and each thread calls net.minecraft.network.NetworkManager.createNetworkManagerAndConnect(). This function uses "lazy loaders" (net.minecraft.util.LazyLoadBase) to initialize some static variables. The issue lies in net.minecraft.util.LazyLoadBase.getValue(). This function is not thread-safe. Below you'll find the code in question with comments explaining exactly what is happening and how to fix it.
package net.minecraft.util; public abstract class LazyLoadBase<T> { private T value; private boolean isLoaded; public T getValue() // NOT THREAD-SAFE. SIMPLE FIX: declare the method synchronized { if (!this.isLoaded) // Thread 1: Condition is true; Thread 2: Condition is false { this.isLoaded = true; // Thread 1: SETS isLoaded to true, BUT VALUE IS STILL NULL this.value = this.load(); } return this.value; // Thread 2: RETURNS NULL because this.load() is not finished in Thread 1 } protected abstract T load(); }Note that depending on the speed of the computer, this bug might not occur. If the first thread finishes quickly enough everything will appear normal.
The bug
Whenever I start my game and go onto the Multiplayer server list, the servers all say "Can't connect to server" but when I refresh the page, it says the normal servers MOTD in the listing.
Code analysis (MCP names), comments, and additional note by Kyle Repinski
I've analyzed the issue and found it's a race condition with the multi-threaded server pinger code. The server pinging code (net.minecraft.client.network.ServerPinger) is run in multiple threads, and each thread calls net.minecraft.network.NetworkManager.createNetworkManagerAndConnect(). This function uses "lazy loaders" (net.minecraft.util.LazyLoadBase) to initialize some static variables. The issue lies in net.minecraft.util.LazyLoadBase.getValue(). This function is not thread-safe. Below you'll find the code in question with comments explaining exactly what is happening and how to fix it.
package net.minecraft.util; public abstract class LazyLoadBase<T> { private T value; private boolean isLoaded; public T getValue() // NOT THREAD-SAFE. SIMPLE FIX: declare the method synchronized { if (!this.isLoaded) // Thread 1: Condition is true; Thread 2: Condition is false { this.isLoaded = true; // Thread 1: SETS isLoaded to true, BUT VALUE IS STILL NULL this.value = this.load(); } return this.value; // Thread 2: RETURNS NULL because this.load() is not finished in Thread 1 } protected abstract T load(); }Note that depending on the speed of the computer, this bug might not occur. If the first thread finishes quickly enough everything will appear normal.
is duplicated by
OMG! Finally this is fixed on SnapShot 18w02a.
On start Minecraft and click on the multiplayer, all servers is dislay online (if server is online):
Thanks for fix this bug in 18w02a SnapShot!
Happening for me all the time.
Ubuntu Server 16.04.2
Xeon 4 Core 3.9 Ghz
128 ECC
Java 8+
Vanilla 1.12Shows offline all the time without constant refreshing.
Player Timed out is extremely common. *with idle off"
Probably explains why its been dead. people think it is offline.
The bug
A few Minecraft servers display "Pinging..." followed by "Can't connect to server", occasionally. This appears to happen when opening the multiplayer/server list for the first time or after the minecraft client startup or when refreshed the multiplayer server lists.
Code analysis
It appears that most parts of the code analysis of MC-73207 apply again. There has been some refactoring (LazyLoadBase uses a Supplier now) which likely replaced the fix by accident.
The following class might be a better replacement for or addition to the LazyLoadBase class. The only restriction is that the factory should be thread-safe.
public class ThreadSafeLazySupplier<T> implements Supplier<T> { private final Supplier<T> factory; private final Object valueCreationMonitor; private volatile boolean hasValue; private volatile T value; public ThreadSafeLazySupplier(final Supplier<T> factory) { this.factory = factory; valueCreationMonitor = new Object(); hasValue = false; } @Override public T get() { if (!hasValue) { synchronized(valueCreationMonitor) { if (!hasValue) { value = factory.get(); hasValue = true; } } } return value; } }
@Play Dash Number f800f8 000000, in 1.12.2 this bug is exist but it's relates to MC-73207 and it's fixed in 1.13 snapshots.
This is the one of the annoying issue since 1.13.
When you start the game and click "Multiplayer", you'll see that the servers are loading a little late.
In early Minecraft versions, like 1.7.2, this issue does not reproduce.
With the release of Minecraft 1.8, we can see the issue MC-73207 that was fixed in 1.13.
But for now we have other two new related issues: MC-154073 + MC-125762.
Hopefully it will fixed soon.

Is this still an issue in the current Minecraft Snapshot 15w47c or later? If so, please update the affected versions in order to best aid Mojang ensuring bugs are still valid in the latest releases/pre-releases.
Confirmed for 1.9, but it doesn't always happen and it doesn't necessarily happen to all server entries. (Using win10 java8)
Refreshing indeed solves the problem. This has been happening to me for quite a while, also in 1.8.
http://imgur.com/gSYX5Fb
The enviroment is supposed to contain pc details.
Really annoying that this hasn't been fixed. It would take less than a minute with the information I provided.
Error of my Minecraft of 'Minecraft game output' : (On pingin the servers)
Minecraft Version: SnapShot: 18w01a
OMG! Finally this is fixed on SnapShot 18w02a.
On start Minecraft and click on the multiplayer, all servers is dislay online (if server is online).
Thanks for fix this bug in 18w02a SnapShot!
Absolutely hate this bug. Probably my OCD lol
But it really annoys me when I have to reload them to see the MOTD
Appears to be fixed for me in 18w02a, too.