In this paper we study the closest-string problem (CSP), which can be defined as follows: Given a finite set 𝒮 = {s1, s2...,sn} of strings, each string with length m, find a center string t of length m minimizing d, such that for every string si ∈ 𝒮 dH(t,si)≤d. By dH(t,si) we mean the Hamming distance between t and si. This is an NP-hard problem, with applications in molecular biology and coding theory. Even though there are good approximation algorithms for this problem, and exact algorithms for instances with d constant, there are no studies trying to solve it exactly for the general case. In this paper we propose three integer-programming (IP) formulations and a heuristic, which is used to provide upper bounds on the value of an optimal solution. We report computational results of a branch-and-bound algorithm based on one of the IP formulations, and of the heuristic, executed over randomly generated instances. These results show that it is possible to solve CSP instances of moderate size to optimality.