curl: (56) Recv failure: Connection reset by peer

简介: curl: (56) Recv failure: Connection reset by peer

解决思路

☺ 以下考虑情况,针对的是docker部署springboot项目,我在springboot的配置文件 application.properties 设置了端口为 8848


1、考虑是不是端口冲突了 ,比如当前运行的项目的端口是8848,然而在项目运行之前已经有一个老项目运行了,且老项目的端口也是8848

# 查看端口占用情况
netstat -lntp | grep 8848


2、考虑项目端口是否忘记暴露了,前提是项目是用dockerfile构建,若是dockerCompose看第三点

■ 具体情况如下:可以看到端口位置为空

  • dockerfile内容:


解决方式1:dockerfile文件中添加上EXPOSE 端口号,且创建启动容器的时候选择端口映射 -p 端口号: 容器端口(expose 8848)

添加上EXPOSE 端口号暴露的方式,只能暴露给其他容器使用,而无法暴露给主机使用,即curl localhost:端口号 是访问不到的,需要做端口映射 -p 宿主的端口:dockerfile暴露的端口,然后才能在宿主机访问


3、考虑项目是否存在多种环境的配置文件[application.yml 或 application.properties],例如既有开发环境[application.properties],也有生产环境的配置文件[application-prod.properties],且你的目的是docker运行的配置文件是生产环境的,则需要在打包前需要选择好生成环境的配置文件

☺ 补充一下命令行 -U clean package 的作用:让打包打包得更加完整,避免打包的jar包没能从远程仓库下载完整,出现was cached in the local repository的错误,加上命令行-U clean package


4、考虑使用-p做端口映射,在测试的时候端口号是否填写正常:


5、在浏览器测试,考虑服务器的安全组或防火墙是否放行:


如果本文对你有帮助的话记得给一乐点个赞哦,感谢!

目录
打赏
0
0
0
0
51
分享
相关文章
ConnectionResetError: [Errno 104] Connection reset by peer|4-16
ConnectionResetError: [Errno 104] Connection reset by peer|4-16
git拉去代码报错"Failed to connect to 127.0.0.1 port 31181: Connection refused"
在克隆`https://example.git/`时遇到错误:"fatal: unable to access 'https://example.git/': Failed to connect to 127.0.0.1 port 31181: Connection refused"。原因是Windows上代理设置未正确关闭,影响了Git配置。解决方法是通过git bash运行命令检查并取消代理:`git config --global http.proxy`和`git config --global --unset http.proxy`。
199 1
 git拉去代码报错"Failed to connect to 127.0.0.1 port 31181: Connection refused"
|
9月前
|
【git】解决:Failed to connect to 127.0.0.1 port 7890: Connection refused
【git】解决:Failed to connect to 127.0.0.1 port 7890: Connection refused
2484 0
如何修复 SSH Client_loop: send disconnect: Broken pipe Error
如何修复 SSH Client_loop: send disconnect: Broken pipe Error
3690 1
ConnectionResetError: [Errno 104] Connection reset by peer
ConnectionResetError: [Errno 104] Connection reset by peer
645 0
filebeat:Failed to publish events caused by: write tcp 5044: write: connection reset by peer
filebeat:Failed to publish events caused by: write tcp 5044: write: connection reset by peer
706 0
filebeat:Failed to publish events caused by: write tcp 5044: write: connection reset by peer
OGG-01232 Receive TCP params error: TCP/IP error 104 (Connection reset by peer), endpoint:
源端: 2015-02-05 17:45:49 INFO OGG-01815 Virtual Memory Facilities for: COM anon alloc: mmap(MAP_ANON) anon free: munmap file alloc: mmap(MAP_SH...
3149 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
230 0
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等