Unable to connect to backup engine on devices with a custom localhost address
Overview
This article describes an issue in which the Code42 agent displays the message "Cannot connect to the backup engine" if the localhost
entries in your computer's hosts file do not point to the default loopback IP addresses. The Code42 agent cannot connect to the Code42 service if the localhost
entries in your hosts file have changed.
To troubleshoot other causes of the "Cannot connect to the backup engine" message, see Cannot connect to background service.
Diagnosing
A changed localhost
entry is likely causing this issue if all of these conditions exist:
- The Code42 agent displays the message "Cannot connect to the backup engine."
- The Code42 agent service.log contains the message:
CPService is already running on localhost:4243
This message indicates the Code42 agent cannot connect to the Code42 service.
- Your hosts file has been modified, either manually or by another application.
Recommended solution
Use caution when following the steps below. Editing the hosts file should only be performed by advanced users. If you have any concerns about this process, contact our Technical Support Engineers. Some versions of Windows also provide automated tools to restore the default values to your hosts file. See External resources below for more details.
Before following the steps below to edit your hosts file, make a backup copy of the file so that you can easily revert your changes in case they cause unintended consequences.
In addition, adding a
#
to the beginning of any line instructs the operating system to ignore that line, but still preserves the content as a "comment" you can reference later. Saving the original content as comments is helpful if you need to revert your changes later.Windows
- Open the Windows Start menu and locate Notepad.
- Right-click Notepad and select Launch as Administrator.
- Select File > Open and navigate to C:\Windows\System32\drivers\etc\host
The hosts file opens. - Edit or remove any localhost entries so that only the following localhost addresses remain. DO NOT edit any other entries in the file.
127.0.0.1 localhost ::1 localhost
- Save the file.
- Start the Code42 service.
Mac
- Open the Finder.
- Go to Applications > Utilities and open Terminal.
- Enter the following command:
sudo nano /private/etc/hosts
If prompted, enter the administrator password. - Edit or remove any localhost entries so that only the following localhost addresses remain. DO NOT edit any other entries in the file.
127.0.0.1 localhost ::1 localhost fe80::1%lo0 localhost
-
Press Control+X to exit.
-
Press Y to confirm the changes.
-
Press Enter to save to the existing location.
- Start the Code42 service.
Linux
- Open Terminal.
- Enter the following command:
sudo nano /etc/hosts
If prompted, enter the administrator password. - Edit or remove any localhost entries so that only the following localhost addresses remain. DO NOT edit any other entries in the file.
127.0.0.1 localhost ::1 localhost
- Press Control+X to exit.
- Press Y to confirm the changes.
- Press Enter to save to the existing location.
- Start the Code42 service.
External resources
- Microsoft Support (Windows): How can I reset the Hosts file back to the default?
- Apple Support (Mac): Restore original hosts file
- StackExchange (Linux): Restore /etc/hosts