Solved my own problem.
My db server is hosted on Microsoft Azure.
I believe the cause is this:
http://serverfault.com/questions/661704/azure-closing-idle-network-connections
Azure has a 4 min timeout for load balancers, which apparently also affects networks that don’t use a load balancer. So it’s an Azure “feature”.
It’s possible to increase this timeout within Azure.