Networking newb here. Under what circumstances could you fail to ping a remote server with the ping command, but still be able to connect to it via other means (as long as it was still TCP/IP)?
As a [self-professed] newb, you will advance more quickly in your network understanding if you flip your thinking around. So instead, ask:
Why would you think "ping" (aka ICMP ECHO packets) would be in any way related to "connect to it" (aka open a TCP socket)?
Success of ICMP ECHO does tell you some facts (eg, IP works between the two points, the end thing responds to ICMP ECHO REQuests, and more.) But you wouldn't jump to the erroneous conclusion that ICMP ECHO success tells you anything explicitly about TCP success.