Most programs that are capable of using IPv6 will use whichever address (IPv4 or IPv6) the system's DNS resolver library reports as the most preferred one for the host.
The preference of the resolver library can adjusted using the /etc/gai.conf file.
The precedence rules are specified in this part of the file:
# precedence <mask> <value>
# Add another rule to the RFC 3484 precedence table. See section 2.1
# and 10.3 in RFC 3484. The default is:
#
#precedence ::1/128 50
#precedence ::/0 40
#precedence 2002::/16 30
#precedence ::/96 20
#precedence ::ffff:0:0/96 10
#
# For sites which prefer IPv4 connections change the last line to
#
#precedence ::ffff:0:0/96 100
The built-in defaults are listed as commented values, but if you specify your own settings, the defaults won't be used at all. So add this to the end of the file:
# To prefer IPv4 over everything else
precedence ::ffff:0:0/96 100
precedence ::1/128 50
precedence ::/0 40
precedence 2002::/16 30
precedence ::/96 20
Note that it is not possible to answer in IPv4 to an incoming connection that arrives using IPv6, or vice versa: by the rules of the IP and TCP protocols, any connection attempt must be answered using the protocol the request was made with.