Articles in this section

Scheduled tasks fail in a server behind NAT: curl error 7 failed to connect to example.com port 443 connection refused

kb: technical Plesk ABT: Group B

Symptoms

  • Scheduled tasks fail with the following error messages:

    curl error 7 failed to connect to example.com port 443 connection refused

  • Attempt to connect to the website fails. For instance, with the following command:

    # wget http://www.example/
    --2020-07-07 07:17:07-- http://www.example/
    Resolving www.example.com (www.example.com)... 127.0.0.1
    Connecting to www.example.com (www.example.com)|127.0.0.1|:443... failed: Connection refused.

  • On the network interface, the internal 192.0.2.2 IP address is used and the domain example.com resolves to external 203.0.113.2 IP address

Cause

Incorrect NAT configuration.

Resolution

Contact the hosting provider responsible for network/NAT configuration and report the issue to them to make it possible to connect to websites' own public IP from the server itself.

Workaround

Modify the hosts file:

For Plesk on Linux:

  1. Connect to the server via SSH

  2. Make a backup of the /etc/hosts file:

    # cp -a /etc/hosts{,.bak}

  3. Edit file and add the following record:

    192.0.2.2 www.example.com example.com

For Plesk on Windows:

  1. Connect to the server via RDP

  2. Create a backup of file C:\Windows\System32\drivers\etc\hosts

  3. Open file C:\Windows\System32\drivers\etc\hosts with a texteditor started as administrator

  4. Add the following line and save the file:

    192.0.2.2 www.example.com example.com

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.