Relais

Is this a "relay" or a relay module? If it is just a relay itself, the coil will require more current than the digital pins can provide, which is why it works hooking it up to power, but not the pin. If so, you require a transistor to switch the power to the coil.