Set DNS nameservers in Ubuntu 20.04 by following this quick tutorial that provides steps for both GUI and command-line interface approaches.

When developing locally the localhost refused to connect is the worst error you can get. See the causes and what solves the error.