Hi,
I think you have not made can up on network.
ip link set can0 up
Please follow all the steps mentioned in the doc.
Also, if you have not connected anything on the bus and just want to send and receive on CAN0, use loopback settings.
ip link set can0 up type can bitrate 500000 loopback on