Plesk

Cannot remove IP address from Plesk server: The IP address 203.0.113.2 is already used for hosting

Symptoms

Cause

Plesk bug PPPM-11183 that is planned to be fixed in one of the next Plesk updates.
Plesk doesn't update the records in its database in case the DNS service is disabled/not installed.:

# plesk db "SELECT d.name,ip.ip_address FROM DomainServices ds INNER JOIN IpAddressesCollections ipac ON ds.ipCollectionId = ipac.ipCollectionId INNER JOIN domains d ON d.id = ds.dom_id JOIN IP_Addresses ip on ipac.ipaddressid=ip.id WHERE ds.type = 'mail' and ipac.ipAddressId = (select id from IP_Addresses where ip_address='203.0.113.2') GROUP BY d.name ASC;"
​+-------------+----------------+
​| name | ip_address |
​+-------------+----------------+
​| example.com | 203.0.113.2 |
​+-------------+----------------+

Resolution

Until the bug is fixed, use the following workaround to switch mail to another IP address and to be able to remove the IP address:

Plesk for Linux

  1. Connect to the server using SSH.

  2. Find the domains using the IP address to be removed:

    # plesk db "SELECT d.name,ip.ip_address FROM DomainServices ds INNER JOIN IpAddressesCollections ipac ON ds.ipCollectionId = ipac.ipCollectionId INNER JOIN domains d ON d.id = ds.dom_id JOIN IP_Addresses ip on ipac.ipaddressid=ip.id WHERE ds.type = 'mail' and ipac.ipAddressId = (select id from IP_Addresses where ip_address='203.0.113.2') GROUP BY d.name ASC;"
    +-------------+----------------+
    | name | ip_address |
    +-------------+----------------+
    | example.com | 203.0.113.2 |
    +-------------+----------------+

  3. Find the IP address used for web hosting on this domain:

    # plesk bin domain --info example.com | grep -i "IP address"
    IP address: 203.0.113.3

  4. Select the option Send from domain IP addresses in Tools & Settings > Mail Server Settings > Outgoing mail mode and click OK at the bottom of the page to apply the change.

  5. Update the domain to use the same IP for web and mail hosting:

    • for one domain:

      # plesk bin domain -u example.com -mail-service-ip 203.0.113.3

    • for all affected domains:

      # for i in $(plesk db -Nse "SELECT d.name FROM DomainServices ds INNER JOIN IpAddressesCollections ipac ON ds.ipCollectionId = ipac.ipCollectionId INNER JOIN domains d ON d.id = ds.dom_id JOIN IP_Addresses ip on ipac.ipaddressid=ip.id WHERE ds.type = 'mail' and ipac.ipAddressId = (select id from IP_Addresses where ip_address='203.0.113.2') GROUP BY d.name ASC;"); do plesk bin domain -u $i -mail-service-ip 203.0.113.3; done

      Note: Replace the IP address 203.0.113.2 in the above command with the one to be removed, and 203.0.113.3 with the one to be used instead for mail hosting.

  6. Roll back to the previous setting in Tools & Settings > Mail Server Settings > Outgoing mail mode and click OK at the bottom of the page to apply the change.

Plesk for Windows

  1. Connect to the server using RDP.

  2. Open the Command Prompt as Administrator.

  3. Create a file with the list of affected domains where…