我正在chromebook上测试来自Termux的php web服务器
php -S 127.0.0.1:8080 -t /sdcard/Download/webserver我试图在Chrome (127.0.0.1:8080)中打开网页,但它返回了以下错误消息: ERR_CONNECTION_REFUSED。它可以通过android在Firefox甚至Chrome浏览器上工作,因此我知道web服务器已经启动并运行。我已经清除了缓存,刷新了DNS,并做了谷歌搜索想出的任何解决方案,但都没有效果。Chrome怎么了?有解决办法吗?
发布于 2017-11-28 14:21:49
安卓应用程序在ChromeOS上运行于一个孤立的环境中,您需要获取ip地址。在termux中,尝试使用ifconfig arc0并查找ip地址,而不是使用127.0.0.1。
发布于 2022-01-21 19:51:38
我所做的就是termux pkg install iproute2并运行ip --json addr show eth0
这清楚可靠地将JSON格式的ipaddress转储到ip.json。
示例:
import { execSync } from 'child_process'
import { readFile } from 'fs'
const ipShowRaw = execSync('ip --json addr show eth0', {encoding: 'utf-8'})
// readFile('./ip.json', {encoding: 'utf-8'}, (e, data) => ipShow = JSON.parse(data))
const ipShow = JSON.parse(ipShowRaw)
const ip = ipShow[0]['addr_info'][0].local
console.log(ip)从bash跑出来:
~ $ pkg install iproute2
~ $ node getIp.mjs
100.115.92.2
~ $ xdg-open 'http://100.115.92.2:8080'最后一行通常会在ChromeOS的chrome上打开一个新选项卡。
发布于 2017-11-28 07:15:16
在您的chrome中可能不允许访问本地域。转到chrome://标志,将“内置异步DNS”设置为“禁用”,然后重新启动浏览器。
也请看一下这个链接。
https://stackoverflow.com/questions/47525471
复制相似问题