Set the "LoginType" setting properly (usually STW FF CAN).
Make sure that the baudrate in PLC Config > CAN# > Module parameters is the same as the baudrate in online > Communication Parameters. The Communication Parameters baudrate determines the rate the PC will try to use to connect to the Bus. Also the NodeID of the controller (found in the controller "base parameters" tab) must be set properly in the Communication Parameters NodeID field.
Also, is the correct CommDLLPath selected in Online -> Communication Parameters? Ex: "C:\Program Files\STW\CoDeSys V2.3 TSP\CANDlls stwpeak2.dll" or "C:\WINDOWS\System32\stwpeak2.dll".
Are other unnecessary programs using the CAN bus? This can sometimes interfere with the login process of Codesys. Use the PCANStat program to see if other programs are on the bus, and if so you can disconnect them by right clicking and selecting "kill client".
Is your CAN bus terminated? A 60 ohm resistor placed across CANH and CANL at one end is all that is necessary for testing, but for a vehicle application there should be 2 120 ohm resistors on the bus, one at each end.
Here is an example of using the second CAN bus (CAN1) on the ESX as a login bus. Note module parameters use a naming convention of CAN1 and CAN2, while the PLC configuration tree lists CAN0 and CAN1.