This paper presents a method to find the optimal topology, pipe sizing, and operational parameters of a district heating system under consideration of one design point. The current high costs of district heating systems set limits regarding the minimum heat demand density required for economic network expansions. Optimized routing with ideal pipe sizing and optimal operating parameters offers a potential for cost reduction. With a lower network temperature, the consideration of nonlinear transport phenomena within the district heating network becomes increasingly important. Therefore, a new nonlinear optimization method is introduced, where graph preprocessing reduces the computational effort of the subsequent nonlinear optimization. A cost penalization method, using a smooth approximation of a Heaviside function is applied to pipe investment costs to account for discrete piping diameters. To guarantee fast convergence of the optimization algorithm, the Jacobian matrixes are calculated and the problem is solved with an interior point algorithm. As a proof of concept, the district heating system for a small fictional town with 42 consumers is optimized and analyzed. The whole nonlinear optimization is performed in 19.37 sec and in most cases discrete or near discrete diameters are achieved in a nonlinear continuous optimization.