CIFS: mount error(112): Host is down

When trying to mount a Windows share using mount, I ran into this problem:

mount -v -t cifs -o username=username,password=password //hostname/sharename /mnt
mount.cifs kernel mount options: ip=XXX.XXX.XXX.XXX,unc=\\hostname\sharename,user=username,prefixpath=sharename,pass=********
mount error(112): Host is down

In my case, the error was due to a protocol mismatch when trying to mount the share: in the latest versions of Windows Server, SMBv1 is disabled.

To reach this conclusion, I ran smbclient in debug mode:

smbclient -L //hostname/sharename -U username -d 3
protocol negotiation failed: NT_STATUS_CONNECTION_RESET

To overcome this issue, I specified the protocol when using mount:

mount -t cifs -o username=username,password=password,vers=3.0 //hostname/sharename /mnt

If you want to use smbclient, add the -m option:

smbclient -L //hostname/sharename -U username -m SMB3