In this paper, we study the largest size A(n, d) of permutation codes of length n, i.e., subsets of the set \(S_n\) of all permutations on n letters with the minimum distance at least d under the Hamming metric. In Abdollahi et al. (Cryptogr. Commun. 15, 891–903 2023) we have developed a method using the representation theory of symmetric groups to find upper bounds on the size of permutation codes in \(S_n\) with the minimum distance of d under the Kendall \(\tau \) -metric. The latter method is used for the permutation codes under the metric induced by Cayley graphs of \(S_n\) . Since the metric induced by any Cayley graph of \(S_n\) is not equivalent to the Hamming metric, we can not use the method for the Hamming metric. In this paper we find a trick by which we can again use the method to find upper bounds for \(A(n, 2t+1)\) . We present three practical results that prove the non-existence of perfect 2-error-correcting codes in \(S_n\) under the Hamming metric for numerous values of n. Specifically, we prove that 91 and 907 are the only values for \(n \le 1000\) for which \(S_n\) may contain a perfect 2-error-correcting code under the Hamming metric. Additionally, we prove that for any integer n such that \(n^2 - n + 2\) is divisible by a prime exceeding \(n-\lfloor \frac{n}{7}\rfloor \) , \( A(n,5)\le \frac{2\times n!}{n^2-n+2}-\dfrac{20n-56}{(n^2-n+2)\sqrt{698n^2-1428n+1274}}\sqrt{\dfrac{n!}{(n-\lfloor \frac{n}{7}\rfloor )!}}. \) The result improves the known upper bounds of A(n, 5) for all integers \(n \ge 35\) such that \(n^2 - n + 2\) is divisible by a prime exceeding \(n-\lfloor \frac{n}{7}\rfloor \) .