Short answer
Most flu injections contain no animal ingredients that raise a problem, so they are fine. The nasal spray given to many children (Fluenz in the UK, FluMist in the US) has contained porcine gelatin. Hanafi muftis who hold that such gelatin stays impure say to ask for the injection instead, which is usually offered. Others allow the spray.
Vaccination is permitted preventive treatment. Where a pork-free alternative of similar effect exists, as with injected flu vaccines, it should be chosen on the Hanafi view that porcine gelatin is not fully transformed; where no alternative exists and doctors advise it, the gelatin version is allowed by need.
The four schools agree on this.
Explanation
The flu vaccine is updated every year and comes in two main forms: an injection, used for most adults, and a nasal spray, used in several countries for children. The injected vaccines are generally made without gelatin. The nasal spray has listed porcine (pig) gelatin as a stabiliser, which is why Muslim parents ask about it. Ingredients can change, so check the current leaflet or ask the nurse.
Most Deobandi muftis hold that pork gelatin is not changed enough to become pure, so medicine containing it is allowed only when there is a real need and no halal alternative (see gelatin in medicine). For the flu, an injected alternative normally exists. In the UK, for example, the NHS has offered children an injected vaccine when the family declines the spray because of the gelatin. On this view, ask for the injection.
Some scholars hold that the gelatin is fully transformed into a new substance (istihalah), and on their view the spray is fine too. Either way, the vaccine itself is lawful prevention: the Prophet ﷺ taught precautions against disease, such as not entering a land struck by plague.
Ask your doctor or pharmacist which vaccine they are offering, ask for a gelatin-free injection if you want one, and do not leave a high-risk family member unvaccinated over this question. For vaccines in general, see are vaccines haram.
Ask a mufti about your own case. This answer explains the general ruling. When the details of your situation matter, as they do here, ask a qualified mufti and give them the full facts. Where to ask a scholar.
The evidence
Quran, Surah Al-Baqara 2:173
إِنَّمَا حَرَّمَ عَلَيْكُمُ ٱلْمَيْتَةَ وَٱلدَّمَ وَلَحْمَ ٱلْخِنزِيرِ وَمَآ أُهِلَّ بِهِۦ لِغَيْرِ ٱللَّهِ ۖ فَمَنِ ٱضْطُرَّ غَيْرَ بَاغٍۢ وَلَا عَادٍۢ فَلَآ إِثْمَ عَلَيْهِ ۚ إِنَّ ٱللَّهَ غَفُورٌۭ رَّحِيمٌ ﴿١٧٣﴾
He has only forbidden to you dead animals, blood, the flesh of swine, and that which has been dedicated to other than Allah. But whoever is forced [by necessity], neither desiring [it] nor transgressing [its limit], there is no sin upon him. Indeed, Allah is Forgiving and Merciful.
Necessity lifts a prohibition, but only where there is no lawful alternative.
Sahih al-Bukhari 5678
Sahih... ما أنزل الله داء إلا أنزل له شفاء ...
"Allah has not sent down any disease without sending down a cure for it."
Seeking prevention and cure is part of using the means Allah made.
Sahih al-Bukhari 5729
Sahih... إذا سمعتم به بأرض فلا تقدموا عليه ...
"If you hear of it (plague) in a land, do not go there."
Taking precautions against disease is part of the Sunnah.
Where the ruling is recorded
- Radd al-Muhtar (Ibn Abidin), Kitab al-Taharah, discussion of treatment with impure and forbidden things. Treatment with a forbidden substance is allowed only when needed and no lawful alternative exists.
- al-Fatawa al-Hindiyya, Kitab al-Karahiyya, chapter on treatment and remedies (al-tadawi wa al-mu'alajat). Preventive and curative treatment is permitted.
Checked by our team. For a more accurate answer to your own situation, consult a scholar. Quran translation by Sahih International. Hadith Arabic from the standard editions of the six books and the Muwatta, with gradings as recorded there; the English is our own rendering. Spotted a mistake? Tell us.