District Heating Networks (DHN) can provide higher efficiencies and better pollution control compared to local heat generation. However, there are still many areas, which can be improved and optimized in these systems. A DHN is a complex distributed system of different customer substations and components such as boilers, accumulators, pipes, and in many cases also turbines for electricity production. How to schedule the components with the objective of maximizing the profit of heat and electricity production over a finite time horizon is receiving increased attention, and is the problem that has been dealt with in this work. This mixed integer linear programming (MILP) problem has been formulated as a unit commitment problem (UCP), which involves finding the most profitable unit dispatch regarding production costs and heat and electricity sell prices, while simultaneously meeting the predicted district heating demands and satisfying network operational constraints. The heating demands within the optimization time horizon are predicted based on season and weather forecasts. In this work, the district heating plant in Uppsala, Sweden, owned by Vattenfall AB, has been considered as a reference plant for modeling and optimization. The optimization model is formulated in Python using Pyomo modeling language, and solved by Gurobi and GLPK solvers. An hourly- based data of five consecutive days is used as the time horizon. The results demonstrate the fact that with an accurate model of the DHN, it is possible to significantly increase the revenue of the DHN by finding the most economical way to dispatch different production components.