
657 F.3d 890 (2011)
Larry Lee MOORE, Plaintiff-Appellant,
v.
MARICOPA COUNTY SHERIFF'S OFFICE, Defendant-Appellee.
No. 10-16736.
United States Court of Appeals, Ninth Circuit.
Argued and Submitted August 8, 2011.
Filed September 13, 2011.
*891 Steven H. Goldblatt, Director, Katherine Bushman, Supervising Attorney, and Adam Bellotti, Certified Law Student, Georgetown University Law Center, Appellate Litigation Program, Washington, D.C., for the plaintiff-appellant.
J. Scott Dutcher, Deputy County Attorney, Maricopa County Office of General Litigation Services, Phoenix, AZ, for the defendant-appellee.
Before: DIARMUID F. O'SCANNLAIN, SUSAN P. GRABER, and CARLOS T. BEA, Circuit Judges.

OPINION
GRABER, Circuit Judge:
Plaintiff Larry L. Moore is a frequent filer of lawsuits and is indigent. In this action, Plaintiff seeks money damages and other relief against Defendant Maricopa County Sheriff's Office resulting from alleged mistreatment of Plaintiff when he was a prisoner. As Plaintiff had done several times before, he sought to proceed in forma pauperis ("IFP") in this case. The district court held that four previous actions filed by Plaintiff qualified as "strikes" under 28 U.S.C. § 1915(g) and, therefore, denied Plaintiff IFP status. *892 Plaintiff timely appeals. Because only two of the four dismissals identified by the district court qualify as "strikes" under the statute, we reverse and remand for further proceedings.
"Plaintiffs normally must pay $350 to file a civil complaint in federal district court, but 28 U.S.C. § 1915(a)(1) allows the district court to waive the fee, for most individuals unable to afford it, by granting IFP status." Andrews v. Cervantes, 493 F.3d 1047, 1051 (9th Cir.2007) (citation omitted). All persons, not just prisoners, may seek IFP status. Id. at 1052 n. 1.
But a prisoner faces an additional hurdle. In a statutory provision "nicknamed the `three-strikes rule,'" id. at 1049, Congress prohibited the grant of IFP status to a prisoner if he or she had filed three or more prior actions, as a prisoner, that were dismissed for certain specified reasons. The provision states:
In no event shall a prisoner bring a civil action or appeal a judgment in a civil action or proceeding under this section if the prisoner has, on 3 or more prior occasions, while incarcerated or detained in any facility, brought an action or appeal in a court of the United States that was dismissed on the grounds that it is frivolous, malicious, or fails to state a claim upon which relief may be granted, unless the prisoner is under imminent danger of serious physical injury.
28 U.S.C. § 1915(g).
Here, the district court held that four of Plaintiff's previously dismissed actions qualify as "strikes." Plaintiff argues that the district court erred because only two of the previously dismissed actions qualify as "strikes." Before reaching the merits of Plaintiff's argument, we must consider whether this appeal is moot.

A. Mootness

While this appeal was pending, Plaintiff was released from jail on parole. Accordingly, Plaintiff is no longer a "prisoner" for purposes of § 1915(g), and the three-strikes rule no longer applies to actions that he files. See 28 U.S.C. § 1915(h) (defining the term "prisoner," which does not include persons released on parole). Defendant argues that this appeal is moot because, as a non-prisoner, Plaintiff could re-file this action and seek IFP status unhindered by the three-strikes rule.[1]
Defendant concedes that the underlying actionan action for damages resulting from alleged mistreatmentis not moot. Additionally, if we rule in Plaintiff's favor on appeal, this action will proceed to the next stage on remand. Defendant's mootness argument hinges on the fact that Plaintiff has a roughly equivalent alternative avenue to reach the same stage of litigation: Plaintiff could re-file this action as a non-prisoner. Because he is no longer a prisoner, Plaintiff automatically would clear the § 1915(g) hurdle.[2]
Plaintiff asserts that filing a new action would not preserve his rights in the same manner as the current action does because, for example, the statute of limitations *893 may have run. We need not consider those arguments, however, because a more fundamental flaw exists in Defendant's mootness argument. When considering whether a case is moot, we ask whether we can grant any effective relief "within the confines of the case itself." Tur v. You-Tube, Inc., 562 F.3d 1212, 1214 (9th Cir. 2009) (per curiam) (emphasis added); see United States Internal Revenue Service v. Pattullo (In re Pattullo), 271 F.3d 898, 901-02 (9th Cir.2001) (order) ("To have jurisdiction, we must be able to grant effective relief within the boundaries of the present case. . . ." (emphasis added)). Because the underlying substantive claims are not moot and because a ruling in favor of Plaintiff would permit those claims to proceed, we can provide effective relief, and this appeal is not moot. If the district court erred in dismissing the case, Plaintiff is entitled to continue to litigate this very case.[3] That is effective relief even if, in theory, some other relief also would be effective. Defendant has not met its heavy burden of establishing mootness.

B. Scope of the Three-Strikes Rule

Plaintiff makes a two-step argument about the rule. First, he argues that a dismissal for lack of subject-matter jurisdiction does not qualify as a "strike" under § 1915(g). Second, Plaintiff argues that, because two of the four dismissals identified by the district court were for lack of subject-matter jurisdiction, the district court erred in denying him IFP status. We review de novo "[t]he district court's interpretation and application of § 1915(g)." Andrews v. King, 398 F.3d 1113, 1118 (9th Cir.2005).

1. Dismissal for Lack of Subject-Matter Jurisdiction and § 1915(g)

The question whether a dismissal for lack of subject-matter jurisdiction constitutes a "strike" for purposes of § 1915(g) is an issue of first impression in this circuit. In a published opinion, the District of Columbia Circuit held that a dismissal for lack of subject-matter jurisdiction does not qualify as a "strike" for purposes of § 1915(g). Thompson v. DEA, 492 F.3d 428, 437 (D.C.Cir.2007). We agree with, and adopt, its reasoning and conclusion.
The text of § 1915(g) provides that a previous case qualifies as a "strike" if it "was dismissed on the grounds that it is frivolous, malicious, or fails to state a claim upon which relief may be granted." "Surely, there is nothing necessarily frivolous or malicious in bringing an action for which the court lacks jurisdiction." Thompson, 492 F.3d at 437; see also id. ("[B]ecause understanding federal court jurisdiction is no mean feat even for trained lawyers, creating a rule that mechanically treats dismissals for lack of jurisdiction as strikes would pose a serious risk of penalizing prisoners proceeding in good faith and with legitimate claims.").
"Equally clearly, a dismissal for lack of jurisdiction is not the same as a dismissal for failure to state a claim: in enacting section 1915(g), Congress chose to mirror the language of Federal Rule of Civil Procedure 12(b)(6), not 12(b)(1)." Id.; cf. Andrews, 398 F.3d at 1121 ("We have held that the phrase `fails to state a claim on which relief may be granted,' as used elsewhere in § 1915, `parallels the language of Federal Rule of Civil Procedure 12(b)(6).'" (quoting Barren v. Harrington, 152 F.3d 1193, 1194 (9th Cir.1998) (order))). The *894 three-strikes rule counts a dismissal as a strike if the court held that the action "fails to state a claim upon which relief may be granted." 28 U.S.C. § 1915(g). Other than verb tense, that text is identical to the text of Federal Rule of Civil Procedure 12(b)(6): "failure to state a claim upon which relief can be granted." Nowhere does the three-strikes rule mention "lack of subject-matter jurisdiction," the text of Rule 12(b)(1). Like the District of Columbia Circuit, we conclude that Congress intended for the three-strikes rule to count 12(b)(6) dismissals but not 12(b)(1) dismissals.[4]See Atl. Sounding Co. v. Townsend, ___ U.S. ___, 129 S.Ct. 2561, 2573, 174 L.Ed.2d 382 (2009) ("We assume that Congress is aware of existing law when it passes legislation. . . ." (citations and internal quotation marks omitted)).

2. Plaintiff's Previous Dismissals

Plaintiff argues that two of the four previous dismissals identified by the district court do not qualify as strikes because they were dismissed for lack of subject-matter jurisdiction. In both cases, Plaintiff filed a complaint but failed to select a valid jurisdictional basis for the action on a form labeled "CIVIL RIGHTS COMPLAINT BY A PRISONER." In one case, he left the jurisdictional basis blank. In the second case, he checked the box "Other" and wrote in "Maricopa County, Superior Court in Arizona." In separate written orders, the district court dismissed the actions.
In the first case, the district court's order stated:
III. Lack of Jurisdiction
Federal courts have limited jurisdiction, and limitations on the court's jurisdiction must neither be disregarded nor evaded. Owen Equip. & Erection Co. v. Kroger, 437 U.S. 365, 374 [98 S.Ct. 2396, 57 L.Ed.2d 274] (1978). The Court is obligated to determine sua sponte whether it has subject matter jurisdiction. See Valdez v. Allstate Ins. Co., 372 F.3d 1115, 1116 (9th Cir.2004). See also Fed.R.Civ.P. 12(h)(3) ("If the court determines at any time that it lacks subject-matter jurisdiction, the court must dismiss the action.").
Rule 8(a) of the Federal Rules of Civil Procedure requires that "[a] pleading that states a claim for relief must contain: (1) a short and plain statement of the grounds for the court's jurisdiction. . . ." In order to proceed in federal court, Plaintiff must demonstrate some right of action and legal entitlement to the damages he seeks. In a case challenging his conditions of confinement while a prisoner, the most likely source of a right to sue is 42 U.S.C. § 1983. The Court has jurisdiction over such cases pursuant to 28 U.S.C. § 1343(a)(3).
Plaintiff has not alleged that this case arises pursuant to 42 U.S.C. § 1983 or that the Court has jurisdiction pursuant to 28 U.S.C. § 1343(a)(3). Instead, he has left the "Jurisdiction" section of the court-approved form blank. See Watson v. Chessman, 362 F.Supp.2d 1190, 1194 (S.D.Cal.2005) ("The court will not. . . infer allegations supporting federal jurisdiction; federal subject matter [jurisdiction] must always be affirmatively alleged."). Therefore, the Court will dismiss Plaintiff's Complaint without prejudice.
. . . .
IT IS ORDERED:
. . . .

*895 (3) The Complaint (Doc. # 1) is dismissed without prejudice for lack of subject matter jurisdiction. Plaintiff has 30 days from the date this Order is filed to file a first amended complaint in compliance with this Order.
(Alterations in original; boldface type omitted.) The district court's order in the second case was identical, with one exception. Instead of stating that Plaintiff did not specify a jurisdictional basis, the order stated: "He has alleged only that the Court has jurisdiction pursuant to `Maricopa County, Superior Court in Arizona.' That is a statement describing a court, not a jurisdictional basis." In both cases, Plaintiff failed to amend within 30 days.
The district court's orders are clear: The actions were dismissed "for lack of subject matter jurisdiction." The district court clearly explained that it must inquire into its jurisdiction and, because Plaintiff did not specify a valid jurisdictional basis, it must dismiss for lack of subject-matter jurisdiction because a jurisdictional basis cannot be inferred.
Defendant does not dispute that the district court dismissed for lack of jurisdiction. Instead, in its response brief on appeal, Defendant argues that the cases "were dismissed for lack of subject matter jurisdiction and for[Plaintiff's] failure to state a claim." Defendant supports that position by reference to certain text in the district court's reasoning that states that, because it lacked subject-matter jurisdiction, the action was dismissed for failure to state a claim.
Viewed in isolation, those portions of the district court's reasoning could be interpreted as having dismissed the action for both reasonslack of jurisdiction and failure to state a claim. Ordinarily, one could view the holdings as alternative holdings, as Defendant urges. In these circumstances, however, it is not possible for the district court to have made this type of alternative holding. A federal court cannot assume subject-matter jurisdiction to reach the merits of a case. Steel Co. v. Citizens for a Better Env't, 523 U.S. 83, 94, 118 S.Ct. 1003, 140 L.Ed.2d 210 (1998). And the Supreme Court has specifically instructed that a district court must first determine whether it has jurisdiction before it can decide whether a complaint states a claim. See Bell v. Hood, 327 U.S. 678, 682, 66 S.Ct. 773, 90 L.Ed. 939 (1946) ("[I]t is well settled that the failure to state a proper cause of action calls for a judgment on the merits and not for a dismissal for want of jurisdiction. Whether the complaint states a cause of action on which relief could be granted is a question of law . . . [that] must be decided after and not before the court has assumed jurisdiction over the controversy.").
The operative portions of the district court's orders are clear: The actions were dismissed for lack of subject-matter jurisdiction. While there may be some ambiguity as to the court's reasoning, we will not interpret that ambiguity in a manner that conflicts with a clear and longstanding Supreme Court directive. The only reasonable interpretation of the district court's orders is that the court dismissed the cases for lack of subject-matter jurisdiction.
Because only two of the four previous dismissals identified by the district court qualify as "strikes" under § 1915(g), we hold that the district court erred in determining that the three-strikes rule prohibits the grant of IFP status to Plaintiff. We remand to the district court for further proceedings consistent with this opinion.
REVERSED and REMANDED.
NOTES
[1]  Defendant also argues that this appeal is moot because Plaintiff cannot prevail on the merits of his claims. The issue on appeal is only whether § 1915(g) prohibits Plaintiff's proceeding IFP; resolution of that issue is a live controversy even if Plaintiff ultimately were to lose on the merits of his underlying claims. We express no opinion on the merits of Plaintiff's underlying claims.
[2]  This is not to say that Plaintiff necessarily qualifies for IFP status. That determination would be up to the district court to make, if properly requested, in the first instance. See also 28 U.S.C. § 1915(e)(2) (requiring the district court to dismiss a case "at any time" if certain conditions are met).
[3]  We emphasize that, on remand, the district court should reconsider anew any IFP application. See supra note 2.
[4]  We note that, like the defendant in Thompson, Defendant here does not challenge that legal conclusion. See 492 F.3d at 437 (stating that "the government wisely conceded that dismissals for lack of jurisdiction do not count as strikes within the meaning of section 1915(g)").
