The safest way to run a generator is to plug it into a piece of electrical equipment called a transfer switch, which is required to meet national electrical codes. This is a combination switch and electrical subpanel. It’s wired directly into the house’s service panel and the generator is plugged into it. When you throw its switch, it does two things. First, it disconnects the house from the grid outside. This prevents power from the generator from flowing outside the house, where it can injure or kill a utility worker. Second, it sends power only to house circuits that you’ve designated. That way, the generator won’t be overloaded.