Justice Kennedy
delivered the opinion of the Court.
We granted certiorari to resolve a Circuit conflict over whether a district court’s failure to advise a defendant of his right to appeal as required by the Federal Rules of Criminal Procedure provides a basis for collateral relief even when the defendant was aware of his right to appeal when the trial court omitted to give the advice. Compare, e. g., Thompson v. United States, 111 F. 3d 109 (CA11 1997) (defendant entitled to relief even if he knew of his right to appeal through other sources); United States v. Sanchez, 88 F. 3d 1243 (CADC 1996) (same); Reid v. United States, 69 F. 3d 688 (CA2 1995) (per curiam) (same), with Tress v. United States, 87 F. 3d 188 (CA7 1996) (defendant not entitled to relief if he knew of his right to appeal); United States v. Drummond, 903 F. 2d 1171 (CA8 1990) (same). We hold that a district court’s failure to advise the defendant of his right to appeal does not entitle him to habeas relief if he knew of his right and hence suffered no prejudice from the omission.
Petitioner Manuel Peguero pleaded guilty to conspiracy to distribute cocaine, in violation of 21 U. S. C. § 846. At a sentencing hearing held on April 22, 1992, the District Court sentenced petitioner to 274 months’ imprisonment. The court did not inform petitioner of his right to appeal his sentence.
In December 1996, more than four years after he was sentenced, petitioner filed a pro se motion to set aside his conviction and sentence. See 28 U. S. C. §2255 (1994 ed., Supp. II). He alleged his counsel was ineffective for various reasons, including the failure to file a notice of appeal pursuant to petitioner’s request. App. 68, 65. The District Court appointed new counsel, who filed an amended motion adding a claim that at the sentencing proceeding the trial court violated Federal Rule of Criminal Procedure 32(a)(2) by failing to advise petitioner of his right to appeal his sentence. This last claim gives rise to the question before us.
The District Court held an evidentiary hearing. Petitioner testified that, upon being sentenced, he at once asked his lawyer to file an appeal. App. 139. Consistent with petitioner’s testimony, the District Court found that, although the sentencing court had failed to advise petitioner of his right to appeal the sentence, petitioner knew of his right to appeal when the sentencing hearing occurred. No. 1:CR-90-97-01 (MD Pa., July 1, 1997), App. 168, 184. The court also credited the testimony of petitioner’s trial counsel that petitioner told counsel he did not want to take an appeal because he hoped to cooperate with the Government and earn a sentence reduction. Id., at 180-181; cf. Fed. Rule Crim. Proc. 35(b) (“The court, on motion of the Government made within one year after the imposition of the sentence, may reduce a sentence to reflect a defendant’s subsequent, substantial assistance in the investigation or prosecution of another person who has committed an offense”).
Relying on our holding in United States v. Timmreck, 441 U. S. 780 (1979), the District Court rejected petitioner’s claim that any violation of Rule 32, without regard to prejudice, is enough to vacate a sentence under § 2255. The court held that petitioner was not entitled to relief because he was actually aware of his right to appeal at the time of sentencing. No. 1:CR-90-97-01, App. 184. The court also rejected petitioner’s ineffective assistance of counsel claim based on its finding that petitioner did not request an appeal. Id., at 180.
The Court of Appeals for the Third Circuit affirmed the ruling. It held that the Rule 32(a)(2) violation was subject to harmless-error review and that, because petitioner was aware of his right to appeal, the purpose of the Rule had been served and petitioner was not entitled to relief. Judgt. order reported at 142 P. 3d 430 (1998), App. 192, 194-195. We granted certiorari. 524 U. S. 982 (1998).
In 1992, when petitioner was sentenced, Federal Rule of Criminal Procedure 32(a)(2) provided:
“Notification of Right To Appeal. — After imposing sentence in a case which has gone to trial on a plea of not guilty, the court shall advise the defendant of the defendant’s right to appeal, including any right to appeal the sentence, and of the right of a person who is unable to pay the cost of an appeal to apply for leave to appeal in forma pauperis. There shall be no duty on the court to advise the defendant of any right of appeal after sentence is imposed following a plea of guilty or nolo con-tendere, except that the court shall advise the defendant of any right to appeal the sentence. If the defendant so requests, the clerk of the court shall prepare and file forthwith a notice of appeal on behalf of the defendant.”
Current Rule 32(c)(5) likewise imposes on the district court the duty to advise the defendant at sentencing of any right to appeal.
The requirement that the district court inform a defendant of his right to appeal serves important functions. It will often be the case that, as soon as sentence is imposed, the defendant will be taken into custody and transported elsewhere, making it difficult for the defendant to maintain contact with his attorney. The relationship between the defendant and the attorney may also be strained after sentencing, in any event, because of the defendant’s disappointment over the outcome of the case or the terms of the sentence. The attorney, moreover, concentrating on other matters, may fail to tell the defendant of the right to appeal, though months later the attorney may think that he in fact gave the advice because it was standard practice to do so. In addition, if the defendant is advised of the right by the judge who imposes sentence, the defendant will realize that the appeal may be taken as of right and without affront to the trial judge, who may later rule upon a motion to modify or reduce the sentence. See Fed. Rule Crim. Proc. 35. Advising the defendant of his right at sentencing also gives him a clear opportunity to announce his intention to appeal and request the court clerk to file the notice of appeal, well before the 10-day filing period runs. See Rule 32(c)(5) (“If the defendant so requests, the clerk of the court must immediately prepare and file a notice of appeal on behalf of the defendant”); Fed. Rule App. Proc. 4(b) (establishing 10-day period for filing appeal, which may be extended for 30 days by district court for “excusable neglect”).
These considerations underscore the importance of the advice which comes from the court itself. Trial judges must be meticulous and precise in following each of the requirements of Rule 32 in every case. It is undisputed, then, that the court’s failure to give the required advice was error.
A violation of Rule 32(a)(2), however, does not entitle a defendant to collateral relief in all circumstances. Our precedents establish, as a general rule, that a court’s failure to give a defendant advice required by the Federal Rules is a sufficient basis for collateral relief only when the defendant is prejudiced by the court’s error. In Hill v. United States, 368 U. S. 424 (1962), for example, the District Court violated the then-applicable version of Rule 32(a) by failing to make explicit that the defendant had an opportunity to speak in his own behalf. The defendant did not allege that he had been “affirmatively denied an opportunity to speak,” that the District Judge had been deprived of any relevant information, or that the defendant “would have had anything at all to say if he had been formally invited to speak.” Id., at 429. The defendant established only “a failure to comply with the formal requirements of the Rule,” ibid., and alleged no prejudice; on these premises, the Court held the defendant was not entitled to collateral relief, id., at 428-429.
So, also, in United States v. Timmreck, collateral relief was unavailable to a defendant who alleged only that the District Court “‘fail[ed] to comply with the formal requirements’” of Rule 11 of the Federal Rules of Criminal Procedure by not advising him of a mandatory special parole term to which he was subject. 441 U. S., at 785. The defendant did not argue “that he was actually unaware of the special parole term or that, if he had been properly advised by the trial judge, he would not have pleaded guilty.” Id., at 784. Having alleged no prejudice, defendant’s “only claim [was] of a technical violation of the Rule” insufficient to justify habeas relief. Ibid.
In this case, petitioner had full knowledge of his right to appeal, hence the District Court’s violation of Rule 32(a)(2) by failing to inform him of that right did not prejudice him. The fact of the violation, standing alone, Hill and Timmreck instruct, does not entitle petitioner to collateral relief.
Our decision in Rodriquez v. United States, 395 U. S. 327 (1969), does not hold otherwise. In Rodriquez, the Court held that when counsel fails to file a requested appeal, a defendant is entitled to resentencing and to an appeal without showing that his appeal would likely have had merit. Id., at 329-330. Without questioning the rule in Rodriquez, we conclude its holding is not implicated here because of the District Court's factual finding that petitioner did not request an appeal. While Rodriquez did note the sentencing court’s failure to advise the defendant of his right to appeal, it did so only in the course of rejecting the Government’s belated argument that the ease should be remanded for fact-finding to determine the reason counsel had not filed the appeal. The court’s failure to advise the defendant of his right was simply one factor — in combination with the untimeliness of the Government’s request and the lengthy proceedings and delay the defendant had already endured — that led the Court to conclude that it was “just under the circumstances” to accord the petitioner final relief at that time without further proceedings. Id., at 331-332. This limited and fact-specific conclusion does not support a general rule that a court’s failure to advise a defendant of the right to appeal automatically requires resentencing to allow an appeal.
Petitioner and his amicus would distinguish Timmreck (and, presumably, Hill) on the ground that the defendant in Timmreck had the opportunity to raise his claim on direct appeal but failed to do so, whereas the absence of the “judicial warning [required by Rule 32(a)(2)] may effectively undermine the defendant’s ability to take a direct appeal.” Brief for Petitioner 20. This argument, however, provides no basis for holding that a Rule 32(a)(2) oversight, though nonprejudicial, automatically entitles the defendant to ha-beas relief. Even errors raised on direct appeal are subject to harmless-error review. Rule 52(a) of the Federal Rules of Criminal Procedure prohibits federal courts from granting relief based on errors that “d[o] not affect substantial rights.” See Rule 52(a) (“Any error, defect, irregularity or variance which does not affect substantial rights shall be disregarded”); see also Bank of Nova Scotia v. United States, 487 U. S. 250, 254-255 (1988) (“[A] federal court may not invoke supervisory power to circumvent the harmless-error inquiry prescribed by Federal Rule of Criminal Procedure 52(a).... Rule 52 is, in every pertinent respect, as binding as any statute duly enacted by Congress, and federal courts have no more discretion to disregard the Rule’s mandate than they do to disregard constitutional or statutory provisions”).
Accordingly, we hold that petitioner is not entitled to habeas relief based on a Rule 32(a)(2) violation when he had independent knowledge of the right to appeal and so was not prejudiced by the trial court’s omission. The judgment of the Court of Appeals for the Third Circuit is
Affirmed.