With a shorter USB extension cable, everything works regardless of the
plugging order.
You've got your answer right there: USB cable length is limited, for two reasons
- Signal deterioration: the longer the line, the weaker the signal, and the more interference both inside the cable itself and with other equipment.
- Response timing: Subsequent USB standards have shorter and shorter response timeframes. If the response doesn't come in that timeframe, negotiation will fail.
In the situation where all peripherals try to connect at the same time, you probably have interference inside the cable between the different signals (Cable crosstalk), which gets worse as the signal gets weaker. If you connect the peripherals one-by-one, the signal is just strong enough to arrive.
You could try with a different high-quality cable or a different hub, but for 5 m lenght no-one can guarantee this will work with standard cables, not even with active cables. Also, you might get it to work today, but it will fail tomorrow. USB-Specs 3.0 and 3.1 have 2m as maximum lenght for passive cable, and active cables usually reach 3m.
That said, you've got some different options:
(A) Optical USB cables will transform your signal at both ends so it can be sent over an optical fibre, and they can be long up to 100 m. Optical cables are very fast, so timing usually is not an issue. However, they can be very expensive.
(B) USB Signal Boosters or repeaters amplify your signal so it will travel farther. However, they are mostly meant to connect one only peripheral, so choose your product well to be sure you can connect a Hub. Also, you might experience lower speeds due to package loss for timing reasons.
(C) Daisy-chain two or three powered USB-hubs:
PC >---2-3m---< HUB 1 >---2-3m---< HUB 2 --> peripherals
This should eliminate timing problems since the HUB 1 will work as intermediary.
You could also consider to put your Hub max. 3m from your PC, and from there on run multiple long cables to each of your periphery.
(D) For completeness, there exist also USB-over-Ethernet-extenders, but they are usually limited to USB 2.0 because of too slow timing for USB 3.0 and speed limits of Ethernet cables.