On my Mac terminal, I can get my Pi ip address using this command line:
arp -n raspberrypi.local
it return the IP address of the pi. and then I can absolutely SSH into the raspberry pi using these command lines:
ssh-keygen -R raspberrypi.local ssh [email protected]
However if I ping the pi, it return request timeout and I also cannot access the vnc viewer.
Everything worked just fine when I first log in to this raspberry pi but then this happened.
A device not responding to ping doesn't mean it has a problem. "Ping" packets (https://it.wikipedia.org/wiki/Internet_Control_Message_Protocol) have to be allowed to reach a destination and the destinations has to be allowed to reply. Usually there's a firewall allowing/denying this kind of traffic.
Assuming the services you're speaking about, are correctly running on the machine (server) you want to connect to: