Sometimes, the default setting of the gpg-agent is to use the gtk version of the pinentry program, however this may not be desirable on headless servers.
It is possible to alter this behaviour by adding an entry to the file ~/.gnupg/gpg-agent.conf (create it if required) for example:
# PIN entry program
pinentry-program /usr/bin/pinentry-curses