cURL connection inside container

macamba

Well-Known Member
Mar 8, 2011
85
5
48
I get the following error in my Wordpress LXC container. I think it has to to with the container but don't know who to solve it.
I tried to add 'local ip mypublicdomain.com' in the /etc/hosts file of the container but that doesn't help. The adjustments are also overwritten after reboot.
Also no sure whether that would be the solution. Thoughts are welcome.

Error: cURL error 7: Failed to connect to mypublicdomain.com port 80: Connection refused (http_request_failed)

The above same error message is shown by WordPress in two error messages:

The REST API encountered an error​

Your site could not complete a loopback request​


Macamba
 
Last edited:
Error: cURL error 7: Failed to connect to mypublicdomain.com port 80: Connection refused (http_request_failed)
Either port 80 is not open or the domain can't be resolved to the local WP.
 
Port 80 is open, i.e. in can reach the site on it's domainname at port 80 and it redirects.
'Or the domain can't be resolved' to the local WP, that's why I tried to add 'local ip domainname' entry in the /etc/hosts file, but that doesn't work either.
 
'Or the domain can't be resolved' to the local WP, that's why I tried to add 'local ip domainname' entry in the /etc/hosts file, but that doesn't work either.
For sure the container needs an DNS server to resolve its queries. This DNS server should also present the IP for the domain. And curl can also use a IP address instead of the DNS name.
 
I used the DNS server of the PVE host which in turn uses the DNS of my internet provider. Ping mydomain.com is actually fine resolved from the WP container. Cannot find how to manual adjust the address cURL uses?
 
Ping mydomain.com is actually fine resolved from the WP container.
PIng may use a different order to resolve domain names. Try dig/nslookup. For the curl issue, you will need to look at your WP (or whatever) to see what it tries to do.
 
NSlookup from the container also fine, i.e.:

root@ct-db10-wordpress:/etc/apache2# nslookup mydomain.com
Server: localip
Address: localip#53

Non-authoritative answer:
Name: mydomain.com
Address: mypublicip

The blockeditor of WP is connecting via cURL...

Command line curl command gives:
curl localip (able to resolve)
curl mydomain.com (not able to resolve)

What is the appropriate location to add local ip mydomain.com as local host entry of the container? Tried /etc/hosts but that is overwritten on reboot?

Update, adjusting the /etc/hosts file makes the error disappear. Although the consequence of the error not, i.e that block editor is still not able to connect. Still remains the question what is the appropriate config for adding entries in local host file without being overwritten at reboot?
 
Last edited:
For completeness of post and help others. The turnkey appliance does still require to adjust host file on server to remove cURL error. But there are no errors on the block editor at all, i.e. works out of the box.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!