Title: Allow external host on http.php
Last modified: December 8, 2020

---

# Allow external host on http.php

 *  [intrapixel](https://wordpress.org/support/users/intrapixel/)
 * (@intrapixel)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/allow-external-host-on-http-php/)
 * I have WordPress installed on a Synology server, is not working any link to install,
   update, rss, etc. that goes to wordpress.org. Is blocked by the ** wp_safe_remote_request**
   function. Specifically for not accomplishing the **same_host** restriction.
 * I would like to keep this part in the code for safety, and I seen that there 
   is a code for ** apply_filters **, how can I make an exception for [https://downloads.wordpress.org/](https://downloads.wordpress.org/)?
 * Tanks for help, everything I have tried has not worked.
    -  This topic was modified 5 years, 5 months ago by [intrapixel](https://wordpress.org/support/users/intrapixel/).

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Moderator [Dion Hulse](https://wordpress.org/support/users/dd32/)
 * (@dd32)
 * Meta Developer
 * [5 years, 5 months ago](https://wordpress.org/support/topic/allow-external-host-on-http-php/#post-13762238)
 * Hi [@intrapixel](https://wordpress.org/support/users/intrapixel/),
 * `wp_safe_remote_request()` should allow requests to WordPress.org downloads &
   API, and RSS feeds normally. The only limitations is that it blocks requests 
   to certain “local” addresses and ports, to avoid issues around WordPress accessing
   things it shouldn’t (For example, being able to access the Synology management
   interface).
 * What’s the exact error message you’re seeing from WordPress? The RSS feed display
   is the simplest place to see it, but you can also try the Site Health screens
   which may also show it.
 *  Moderator [Dion Hulse](https://wordpress.org/support/users/dd32/)
 * (@dd32)
 * Meta Developer
 * [5 years, 5 months ago](https://wordpress.org/support/topic/allow-external-host-on-http-php/#post-13762271)
 * [@intrapixel](https://wordpress.org/support/users/intrapixel/) Also, make sure
   you do NOT have `WP_ACCESSIBLE_HOST` or `WP_HTTP_BLOCK_EXTERNAL` defined in your
   wp-config.php file, or in a synology-helper plugin (although these should both
   be flagged in Site Health I believe)
 *  Thread Starter [intrapixel](https://wordpress.org/support/users/intrapixel/)
 * (@intrapixel)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/allow-external-host-on-http-php/#post-13763835)
 * Thanks for answering me. The errors are…
    In any update: “An error occurred while
   updating _anything _Download failed. A valid URL was not provided.” In theme 
   install: “Downloading installation package from [http://downloads.wordpress.org/theme/](http://downloads.wordpress.org/theme/)
   _anyfile_.zip… Download failed. A valid URL was not provided.” In admin Dashboard,
   WordPress news: “Error RSS: WP HTTP Error: A valid URL was not provided.”
 * If I change “wp_safe_remote_request ()” to “$ args [‘reject_unsafe_urls’] =  
   true  false” that allow to get news on Dashboard. For updates and installs I 
   need to change that on “wp_safe_remote_get ()”.
 * My problem is whit “reject_unsafe_urls” is marking unsafe if it is not on localhost.
   I want to now how write the right code to add arguments to set wordpress.org 
   as safe.
    -  This reply was modified 5 years, 5 months ago by [intrapixel](https://wordpress.org/support/users/intrapixel/).
    -  This reply was modified 5 years, 5 months ago by [intrapixel](https://wordpress.org/support/users/intrapixel/).
 *  Moderator [Dion Hulse](https://wordpress.org/support/users/dd32/)
 * (@dd32)
 * Meta Developer
 * [5 years, 5 months ago](https://wordpress.org/support/topic/allow-external-host-on-http-php/#post-13775043)
 * [@intrapixel](https://wordpress.org/support/users/intrapixel/) Sorry for the 
   delayed follow up (If you mention me by [@dd32](https://wordpress.org/support/users/dd32/)
   in your reply I’ll be able to get back to you faster)
 * > My problem is whit “reject_unsafe_urls” is marking unsafe if it is not on localhost.
   > I want to now how write the right code to add arguments to set wordpress.org
   > as safe
 * By default, that IS a safe URL, so I think the problem here is that something(
   not WordPress itself) is triggering a failure case where it thinks that’s NOT
   safe.
 * > A valid URL was not provided
 * That makes me think that [wp_http_validate_url()](https://developer.wordpress.org/reference/functions/wp_http_validate_url/)
   is returning false, looking through that function, I suspect that the likely 
   cause is a DNS resolution issue – if `gethostbyname( 'wordpress.org' )` doesn’t
   return an IP it can fail.
 * I think your best bet is to add some debugging and call `wp_http_validate_url('
   https://wordpress.org/' )` and see where it’s failing and returning false – that
   function call should return the URL there if it’s working correctly.
    -  This reply was modified 5 years, 5 months ago by [Dion Hulse](https://wordpress.org/support/users/dd32/).
 *  Thread Starter [intrapixel](https://wordpress.org/support/users/intrapixel/)
 * (@intrapixel)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/allow-external-host-on-http-php/#post-13776517)
 * [@dd32](https://wordpress.org/support/users/dd32/) Thanks. Yes, debug mode is
   active, and when I go to for example install new theme to see the “invalid url”
   error, nothing happen in the log file:
 *     ```
       called site
       single site, get site license or else default settings
       ```
   
 * I must do something different in debug?
 *  Moderator [Dion Hulse](https://wordpress.org/support/users/dd32/)
 * (@dd32)
 * Meta Developer
 * [5 years, 5 months ago](https://wordpress.org/support/topic/allow-external-host-on-http-php/#post-13784252)
 * My apologies [@intrapixel](https://wordpress.org/support/users/intrapixel/) by
   debugging I meant adding something into the function so that where it looked 
   like:
 *     ```
       if ( condition1 ) {
          var_dump( "Condition 1 caused it to fail" );
          return false;
       }
       ```
   
 * I’ve copied the code from WordPress 5.6 into a gist to add some debugging: [https://gist.github.com/dd32/a9e9e89101f7e4a18200376649aa3b55](https://gist.github.com/dd32/a9e9e89101f7e4a18200376649aa3b55)
 * If you update the function with that and then run a few requests, you should 
   see it output the reasoning for it being an invalid url.
 *  Thread Starter [intrapixel](https://wordpress.org/support/users/intrapixel/)
 * (@intrapixel)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/allow-external-host-on-http-php/#post-13786884)
 * [@dd32](https://wordpress.org/support/users/dd32/) I add the code to http.php
   and now the error I got is this:
 * `Installation failed: string(146) "wp_http_validate_url 'https://downloads.wordpress.
   org/theme/twentytwenty.1.6.zip' is invalid, gethostbyname() failed to find correct
   DNS for site." {"success":false,"data":{"install":"theme","slug":"twentytwenty","
   debug":["Downloading installation package from https:\/\/downloads.wordpress.
   org\/theme\/twentytwenty.1.6.zip…","Download failed. A valid URL was not provided."],"
   errorMessage":"Download failed. A valid URL was not provided."}}`
    -  This reply was modified 5 years, 5 months ago by [intrapixel](https://wordpress.org/support/users/intrapixel/).
 *  Moderator [Dion Hulse](https://wordpress.org/support/users/dd32/)
 * (@dd32)
 * Meta Developer
 * [5 years, 5 months ago](https://wordpress.org/support/topic/allow-external-host-on-http-php/#post-13800284)
 * > I add the code to http.php and now the error I got is this… gethostbyname()
   > failed to find correct DNS for site.
 * Right, so your problem is that DNS resolution is broken, as I alluded to above.
 * I’m not familiar enough with how synology works, but I think it’s docker based?
   you might need to force it to restart the instances/apps if they started before
   there was internet access or something.. or maybe even restarting the entire 
   device..
 * Unfortunately this isn’t really a WordPress problem, but rather a PHP/Synology
   problem, so you might be able to get more help through a Synology support forum.
   Mentioning that `gethostbyname( 'wordpress.org' )` isn’t working.
 *  Thread Starter [intrapixel](https://wordpress.org/support/users/intrapixel/)
 * (@intrapixel)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/allow-external-host-on-http-php/#post-13804435)
 * [@dd32](https://wordpress.org/support/users/dd32/) It’s not on docker, and I 
   restart several times the server. Thank you very much for your help, now that
   I know what the error is, I will continue looking why gethostbyname does not 
   work solving the DNS.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Allow external host on http.php’ is closed to new replies.

## Tags

 * [http.php](https://wordpress.org/support/topic-tag/http-php/)

 * In: [Localhost Installs](https://wordpress.org/support/forum/localhost-installs/)
 * 9 replies
 * 2 participants
 * Last reply from: [intrapixel](https://wordpress.org/support/users/intrapixel/)
 * Last activity: [5 years, 5 months ago](https://wordpress.org/support/topic/allow-external-host-on-http-php/#post-13804435)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
