How did navies before the invention of radio know a port was not hostile?

by conn77

If a ship was sailing from India to the UK for example, it would have to make several stops at ports around Africa, how would the crew know that the designated port was still friendly?

Did many ships looking to take on supplies get attacked or captured because of this?

khosikulu

There are two sides to this 'not knowing' equation. They [edit: the ports] also didn't necessarily know matters, unless connected telegraphically or visited by a ship, and the ships approaching would have to observe from a distance to try and suss the situation out or land a party for a closer look, but be prepared to fight if they were wrong--so actually entering a well-defended port would have been right out. This was borne out early in the voyage of the German raider (light cruiser) SMS Emden and her prize/collier Buresk in Sept-Oct 1914, which called at the British-held island of Diego Garcia, whose garrison did not know war had broken out. The Germans were surprised at this, and had scouted to be sure no warships were present--prepared clearly to hold them at gunpoint, but just as happy to lie! So Captain Müller et al did not disabuse the British of this notion, and used the time (from 9 until 10 October 1914!) to clean their hull of fouling and put back to sea to raid further. (Emden, on the other hand, had a wireless set that it used to track the proximity of the British cruisers hunting her.) When asked about the situation in Europe, Captain Müller reputedly said they were on a very long cruise and as far as they knew peace was intact. Explaining the Emden's condition to a British planter and part time official, not to mention its presence in distant Diego Garcia, they pretended to be victims of foul weather blown off course during joint exercises with the French and British squadrons! No news had come since at least late July, and if they were suspicious, the judicious sharing of liquor and tobacco seems to have soothed them.

Keith Yates's Graf Spee's Raiders, pp. 71-74, is the source I have to hand that talks about this episode. [edit 2: As far as merchant ships calling at a port that is hostile, such a ship would of course be seized, but I don't have any numbers to hand. Shipboard wireless was becoming incredibly common in the years prior to WWI though not at all universal and often lacking in power or intermittently used. It was arguably more likely for remote ports to lack knowledge than ships at sea whose ability to transmit was literally life and death, at least for places like Diego Garcia--which HMS Hampshire visited five days after Emden, after guessing they were headed that way. Yes, it was evidently a very embarrassing conversation. As one final note to underscore the reconnaissance point, Graf von Spee's main squadron had a less propitious example in early December 1914. They--inlcuding his two armored cruisers, SMS Scharnhorst and SMS Gneisenau--were approaching the Falklands with an eye to raid if necessary. However, they fled when they spotted the tripod masts of Admiral Sturdee's battlecruisers HMS Invincible and HMS Inflexible in the harbor, a detachment sent specifically to chase him down that was both faster and better-armed. By that time Spee's smoke had been spotted, however, and the result was the destruction of much of Spee's squadron at the Battle of the Falkland Islands once the battlecruisers got steam up and pursued, although some did slip away. There are other examples of this kind of recon, like the Russian fleet before Tsushima sussing out that the Japanese had already taken Port Arthur in 1905.]

TL;DR: Cues from visual reconnaissance and, usually, some kind of preparation for being wrong.