High efficiency is strongly demanded for gas turbines to reduce CO2 emissions. In order to improve the efficiency of gas turbines, the turbine inlet temperature is being raised higher. In that case, the turbine blade loading is higher and secondary flow loss becomes a major source of aerodynamic losses due to the interaction between the horseshoe vortex and the strong endwall cross flow. One of the authors have optimized a boundary layer fence which is a partial vane to prevent cross-flow from pressure-side to suction-side between blade to blade. However, it was also found that installing the fence leads to increase another loss due to tip vortex, wake and viscosity. Therefore, in this paper, we focused on the endwall contouring and the positive effect findings from the boundary layer fence were used to study its optimal shape. Firstly, the relationship between the location of the endwall contouring and the internal flow within the turbine cascade was investigated. Two patterns of contouring were made, one is only convex and another is just concave, and the secondary flow behavior of the turbine cascade was investigated respectively. Secondly, the shape was designed and the loss reduction effect was investigated by using optimization method. The optimized shape was manufactured by 3D-printer and experiment was conducted using cascade wind tunnel. The total pressure distributions were measured and compared with CFD results. Furthermore, flow near the endwall and the internal flow of the turbine cascade was experimentally visualized. The internal flow in the case of a flat wall (without contouring), with a fence, and with optimized endwall contouring were compared by experiment and CFD to extract the each feature.