Codon optimality refers to the effect that codon composition has on messenger RNA (mRNA) stability and translation level and implies that synonymous codons are not silent from a regulatory point of view. Here, we investigated the adaptation of virus genomes to the host optimality code using mosquito-borne dengue virus (DENV) as a model. We demonstrated that codon optimality exists in mosquito cells and showed that DENV preferentially uses nonoptimal (destabilizing) codons and avoids codons that are defined as optimal (stabilizing) in either human or mosquito cells. Human genes enriched in the codons preferentially and frequently used by DENV are upregulated during infection, and so is the tRNA decoding the nonoptimal and DENV preferentially used codon for arginine. We found that adaptation during single-host passaging in human or mosquito cells results in the selection of synonymous mutations towards DENV’s preferred nonoptimal codons that increase virus fitness. Finally, our analyses revealed that hundreds of viruses preferentially use nonoptimal codons, with those infecting a single host displaying an even stronger bias, suggesting that host–pathogen interaction shapes virus-synonymous codon choice.