1、报错:dns_get_record(): DNS Query failed。如图1

$records = dns_get_record($host, DNS_SRV);
2、打印 $host,其值为:https://object-wp.local/WP_ADMIN_USERNAME=admin
3、在浏览器中打开:https://object-wp.local/WP_ADMIN_USERNAME=admin ,响应 404。但是确定 https://object-wp.local 是支持的。如图2

4、当以 http:// 开头时,仍然报错:Warning: dns_get_record(): DNS Query failed。如图3

<?php
$host = 'http://object-wp.local/WP_ADMIN_USERNAME=admin';
$records = dns_get_record($host, DNS_SRV);
?>
5、在浏览器中打开:http://object-wp.local/WP_ADMIN_USERNAME=admin ,响应 404。确定 https://object-wp.local 是不受支持的。WEB 服务器未监听 80 端口。如图4

6、参考可以配置一个同时处理 HTTP 和 HTTPS 请求的服务器。https://nginx.org/en/docs/http/configuring_https_servers.html 。
server {
listen 80;
listen 443 ssl;
}
7、在浏览器中打开:http://object-wp.local/WP_ADMIN_USERNAME=admin ,响应 404。但是确定 http://object-wp.local 已经是支持的。如图5

8、当以 http:// 开头时,仍然报错:Warning: dns_get_record(): DNS Query failed。
<?php
$host = 'http://object-wp.local/WP_ADMIN_USERNAME=admin';
$records = dns_get_record($host, DNS_SRV);
?>
9、当不以 http:// 开头时,仅剩下纯粹的域名,不再报错。结果为空数组。
<?php
$host = 'object-wp.local';
$records = dns_get_record($host, DNS_SRV);
print_r($records);
?>
Array
(
)
10、当不以 http:// 开头时,仅剩下纯粹的域名,且去掉参数:DNS_SRV。不再报错。结果不为空数组。如图6

<?php
$host = 'object-wp.local';
$records = dns_get_record($host);
print_r($records);
?>
Array
(
[0] => Array
(
[host] => object-wp.local
[class] => IN
[ttl] => 604800
[type] => A
[ip] => 127.0.0.1
)
)
11、由此可以确认,程序代码的处理逻辑上存在一定的问题。至少说明其是不支持 https:// 的相应配置的。
需要长期技术维护或远程问题排查?
我是拥有 15+ 年经验的 PHP / Go 后端工程师,长期关注已有系统维护、Bug 修复、性能优化、服务器排查、WordPress 网站维护和小功能迭代。
如果你的项目遇到以下情况,可以先从一次小问题排查开始合作:
- ✅ PHP / Laravel / Yii2 老项目无人维护
- ✅ Go / Gin 后端接口需要排查或优化
- ✅ WordPress 网站访问慢、报错或插件冲突
- ✅ Nginx / MySQL / Redis / Linux 服务器异常
- ✅ CDN / Cloudflare / DNS / HTTPS 配置问题
- ✅ 需要长期远程技术支持或兼职维护
更多介绍请查看:关于我 & 合作
微信:13980074657
邮箱:shuijingwanwq@gmail.com
Telegram:@shuijingwan
GitHub:https://github.com/shuijingwan

发表回复