使用frp时遇到的问题connect: connection refuseddial tcp xxxx:7000: connect: connection refused

简介: 最近在做的项目需要用到frp来做代理连接本地内网机,卡在最后启动客户端的时候,提示报错:login to server failed: dial tcp xxxx:7000: connect: connection refuseddial tcp xxxx:7000: connect: connection refused!!找了很多尝试的办法,现在给大家列一下希望对大家有帮助。

最近在做的项目需要用到frp来做代理连接本地内网机,卡在最后启动客户端的时候,提示报错:login to server failed: dial tcp xxxx:7000: connect: connection refuseddial tcp xxxx:7000: connect: connection refused!!找了很多尝试的办法,现在给大家列一下希望对大家有帮助。


1. frp基本用法

下载frp

搜索github下载到frp,服务端frps/客户端frpc。。下载的时候要注意自己本地内网机的cpu版本和服务端cpu架构


我的电脑是mac M1PRO版本 下载的是:darwinarm64


服务器是X86_64(centos服务器查看cpu架构的指令是:uname -m)下载的是:linux_amd64

f11975563c6e0186a75e2089642bf0a4.png

1.修改 frps.ini 文件,设置监听 HTTP 请求端口为 8080:

[common]
bind_port = 7000
vhost_http_port = 8080

2.修改 frpc.ini 文件,假设 frps 所在的服务器的 IP 为 x.x.x.x,local_port 为本地机器上 Web 服务监听的端口, 绑定自定义域名为 custom_domains。

 [common]
server_addr = x.x.x.x
server_port = 7000
[web]
type = http
local_port = 80
custom_domains = www.yourdomain.com
[web2]
type = http
local_port = 8080
custom_domains = www.yourdomain2.com


3.分别启动 frps 和 frpc。


4.将 www.yourdomain.com 和 www.yourdomain2.com 的域名 A 记录解析到 IP x.x.x.x,如果服务器已经有对应的域名,也可以将 CNAME 记录解析到服务器原先的域名。或者可以通过修改 HTTP 请求的 Host 字段来实现同样的效果。


5.通过浏览器访问 http://www.yourdomain.com:8080 即可访问到处于内网机器上 80 端口的服务,访问 http://www.yourdomain2.com:8080 则访问到内网机器上 8080 端口的服务。


先启动服务端frps,启动指令:

nohup ./frps -c frps.ini >/dev/null 2>&1 &

客户端启动指令:

./frpc -c frpc.ini

2.启动客户端的时候遇到问题:login to server failed: dial tcp xxxx:7000: connect: connection refuseddial tcp xxxx:7000: connect: connection refused

解决问题:


先查看服务端有没有正常启动成功,成功提示如下:

frps uses config file: frps.ini
frps tcp listen on 0.0.0.0:7000
http service listen on 0.0.0.0:8080
frps started successfully

客户端启动时提示:


login to server failed: dial tcp xxxx:7000: connect: connection refuseddial tcp xxxx:7000: connect: connection refused


1. 检查服务器有没有放行7000和8080端口

image.png


2.检查contos服务器防火墙有没有开放7000和8080端口

1.开放7000端口

firewall-cmd --zone=public --add-port=7000/tcp --permanent 

2.配置立即生效

firewall-cmd --reload  

3.查看防火墙所有开放的端口

firewall-cmd --zone=public --list-ports

cfc5a88d35745d91c8f8aa06e9cd960d.png

再次在本地客户端上启动:./frpc -c frpc.ini


问题解决!!!!

相关实践学习
基于函数计算快速搭建Hexo博客系统
本场景介绍如何使用阿里云函数计算服务命令行工具快速搭建一个Hexo博客。
相关文章
|
3天前
|
分布式计算 Hadoop 网络安全
[m1pro ] ssh: connect to host localhost port 22: Connection refused
[m1pro ] ssh: connect to host localhost port 22: Connection refused
|
6月前
|
Kubernetes 网络协议 容器
kubectl命令报错:Unable to connect to the server: dial tcp XXX:16443: connect: no route to host
kubectl命令报错:Unable to connect to the server: dial tcp XXX:16443: connect: no route to host
303 0
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
161 0
|
运维 网络协议 网络安全
Closed socket connection for client /39.103.162.230:56100 (no session established for client)
Closed socket connection for client /39.103.162.230:56100 (no session established for client)
327 0
Closed socket connection for client /39.103.162.230:56100 (no session established for client)
The connection to the server ip:6443 was refused - did you specify the right host or port
The connection to the server ip:6443 was refused - did you specify the right host or port
Failed to connect to 127.0.0.1 port 1080: Connection refused package 问题解决方法
Failed to connect to 127.0.0.1 port 1080: Connection refused package 问题解决方法
651 0
Failed to connect to 127.0.0.1 port 1080: Connection refused package 问题解决方法
|
Android开发
解决as connection refused: connect错误
解决as connection refused: connect错误
1012 0
解决as connection refused: connect错误