GRB041219A is one of the longest and brightest Gamma-Ray Bursts (GRB) ever observed. It was discovered by the INTEGRAL satellite, and thanks to a precursor intervening about 300 s before the bulk of the burst, ground based telescopes were able to catch the rarely-observed prompt emission in the optical and in the near infrared bands. After a detailed analysis of its prompt gamma-ray emission, as observed with IBIS and SPI on board INTEGRAL, and of the available X-ray afterglow data collected by XRT on board Swift, we present the multi-band near infrared imaging data, collected at the TNG, and the CFHT, that allowed us to identify the host galaxy of the GRB as a nearby, underluminous, irregular galaxy of 5x109 solar masses at redshift z=0.31. Thanks to this distance measurement, we interpret the broad-band prompt optical to gamma-ray emission of the GRB, within the internal shock, and the reverse shock model. We were able to reproduce the GRB light curves and spectra by computing the emission by relativistic electrons accelerated by successive propagating shock waves within the relativistic flow.