A typical convention in UNIX is that programs (usually) read their startup configuration from various predefined files. This is merely a tradition, not anything defined by POSIX or any other standard. A typical UNIX program e.g.
foobar would read, in the following order of precedence:
~/.foobarrc ## User specific configuration parameters
/etc/foobarrc ## Global parameters, depending on taste
## `/etc/foobar/*(.conf)' might be chosen too
There might be a fallback in
/usr/share/ but that is not very common.
curl here following the convention and reading it's initial configuration from
~/.curlrc. And by doing
echo ipv4 >>~/.curlrc, you have appended the string
ipv4 to the file
ipv4 has a special meaning to
curl will use IPv4 for host resolution then. This is analogous to using
curl's argument from command line, but saving to
~/.curlrc makes this permanent.
As you have set
ipv4 in there and now everything works for you, presumably you have IPv6 configured, and
curl were previously using IPv6 for (successful) host resolution, so no fallback to IPv4. The connection to the site was failing because not all sites have their webservers configured to listen on IPv6 addresses, so the
socket() call would fail as we can see in this case.