I'm a bit confused here..
I have a couple of 12V components (compressor, solenoid valves etc.) which are hooked up with an 8-channel 5V relay powered by the Arduino.
All the 12V components are powered by en external power supply and draws around 1.5A.
In the beginning the Arduino was powered by an 9V batteri through the Barrel jack, but couldn't turn on all the relays..
My question is: Can I supply the Arduino from the same external 12V power suppply and through the barrel jack? My idea is to supply the arduino with enough current to turn on all the relays.
The Arduino cannot power all of the relays regardless of what you power it with.
You can get a buck converter to step down the 12V to 5V, then use that to separately power the Arduino and the relay board. There is never a reason to bottleneck a current flow by running the power for demanding devices through the Arduino.
Yes, but it cannot supply the current required by 8 relay coils, especially since you probably have one of those hobby grade non-latching relay boards. These suck current continuously to hold each and every relay at charged position.
Your relay board may also have a jumper to set isolation, but until you show a pic or a product info link, it's just guesses here.
Google the model number on one of those relays. See what the current requirement is. The drain on the Arduino's reg should be less than 500mA. Even less depending on input. If it has to regulate down from 9V, it's about 350mA, at 12V it's about 200mA.
As you already have been told, the Arduino can't power 8 relays.
On a 12volt supply (DC socket), one relay might be ok. Maybe two for a short while.
When more are active, the regulator will overheat and shut down (if you're lucky).
The Arduino will reboot after that (what you're experiencing)
An 8-relay board needs a dedicated 5volt/1Amp (cellphone/tablet) supply.
No way around that.
Post a diagram, showing everything in your setup.
Leo..
Code may also come in handy.
Complete sketch, posted with code tags.
If you power your Arduino from 12V, and you really manage to max out the power supply by having all relays enabled, most likely you'll see it all go up in a puff of smoke (or, if you're lucky, the overheating protection kicks in and shuts everything down - this may be what you're seeing already)... your Arduino's regulator can supply some 500 mA. At 9V, that'd be 2W to dissipate. At 12V, it's 3.5W. That's not going to go well for long in a small SMD package without heat sink.
Those relays should have a transistor or MOSFET built in, to switch the power to them. That way you can connect them to an external power supply and control them from your Arduino.
Consider replacing your relays by MOSFETs. Great for switching 12V loads, and they can be operated directly from your Arduino.