On a new installation we experienced trouble where problems with images would time out. The error message suggested that there may be an infinite loop in the problem but looking at the details of the error message we saw that the message was generated by PGalias.
The actual bug was that in setting up the server, in the /etc/hosts file we had the entry
1.2.3.4 wwmaaserver
Changing this to
1.2.3.4 wwmaaserver courses1.maa.org
solved the problem.
Maybe this hint will help someone in the future.