解决 Error starting userland proxy: listen tcp 0.0.0.0:6379: bind: address already in use

本文涉及的产品
云数据库 Redis 版,社区版 2GB
推荐场景:
搭建游戏排行榜
简介: 解决 Error starting userland proxy: listen tcp 0.0.0.0:6379: bind: address already in use

今天启动redis突然出现连接端口有问题,错误如下:

truedei@truedei:~$ 
truedei@truedei:~$ sudo docker start redis
Error response from daemon: driver failed programming external connectivity on endpoint redis (87977922525bd67cb6e39c26b2f0229081ff428693991d923c595752a733d41b): Error starting userland proxy: listen tcp 0.0.0.0:6379: bind: address already in use
Error: failed to start containers: redis
truedei@truedei:~$

就查了下端口,果然有在使用的:

truedei@truedei:~$ netstat -ntpl |grep 6379
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 127.0.0.1:6379          0.0.0.0:*               LISTEN      -                   
truedei@truedei:~$

查一下是谁在占用,让我很是惊讶,居然是他自己,端口被占用了,而且还没启动

truedei@truedei:~$ ps -aux |grep 6379
redis     1397  0.0  0.0  42608  2292 ?        Ssl  07:30   0:00 /usr/bin/redis-server 127.0.0.1:6379
truedei   5096  0.0  0.0  14536   976 pts/4    S+   07:33   0:00 grep 6379
truedei@truedei:~$ 
truedei@truedei:~$ sudo docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
truedei@truedei:~$ 
truedei@truedei:~$

先结束掉在说,奇怪的是,杀都杀不掉

truedei@truedei:~$ sudo kill -9 1397
truedei@truedei:~$ ps -aux |grep 6379
redis     8263  0.0  0.0  42608  2164 ?        Ssl  07:35   0:00 /usr/bin/redis-server 127.0.0.1:6379
truedei   8291  0.0  0.0  14536   984 pts/4    S+   07:35   0:00 grep 6379
truedei@truedei:~$

仔细看了一下这个redis并不是docker中安装的redis,而是在本机的:

/usr/bin/redis-server

那就停止掉本机的,果然可以了:

truedei@truedei:~$ /etc/init.d/redis-server stop
[ ok ] Stopping redis-server (via systemctl): redis-server.service.
truedei@truedei:~$ 
truedei@truedei:~$ ps -aux |grep 6379
truedei  10583  0.0  0.0  14536   948 pts/4    S+   07:37   0:00 grep 6379
truedei@truedei:~$ 
truedei@truedei:~$

然后再启动:

truedei@truedei:~$ 
truedei@truedei:~$ sudo docker start redis
redis
truedei@truedei:~$ 
truedei@truedei:~$ sudo docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
85cb7d83a2ff        redis               "docker-entrypoint.s…"   22 hours ago        Up 5 seconds        0.0.0.0:6379->6379/tcp   redis
truedei@truedei:~$ 
truedei@truedei:~$

总结:

出现这种情况的大多数原因都是自己的本机安装了redis,而docker中安装的redis与物理机绑定的端口号是相同的,所以就造成了这个原因。

解决方案有很多种:

1、直接卸载物理机的redis

2、不让开机启动

3、修改docker映射的端口号

4、…等

如果对你有帮助,可以分享给你身边的朋友。或者给俺点个大大的赞和大大的评论,点赞和评论就是给我最大的支持,感谢。

水平有限,难免会有疏漏或者书写不合理的地方,欢迎交流讨论。

相关实践学习
基于Redis实现在线游戏积分排行榜
本场景将介绍如何基于Redis数据库实现在线游戏中的游戏玩家积分排行榜功能。
云数据库 Redis 版使用教程
云数据库Redis版是兼容Redis协议标准的、提供持久化的内存数据库服务,基于高可靠双机热备架构及可无缝扩展的集群架构,满足高读写性能场景及容量需弹性变配的业务需求。 产品详情:https://www.aliyun.com/product/kvstore     ------------------------------------------------------------------------- 阿里云数据库体验:数据库上云实战 开发者云会免费提供一台带自建MySQL的源数据库 ECS 实例和一台目标数据库 RDS实例。跟着指引,您可以一步步实现将ECS自建数据库迁移到目标数据库RDS。 点击下方链接,领取免费ECS&RDS资源,30分钟完成数据库上云实战!https://developer.aliyun.com/adc/scenario/51eefbd1894e42f6bb9acacadd3f9121?spm=a2c6h.13788135.J_3257954370.9.4ba85f24utseFl
目录
相关文章
|
Arthas 测试技术 网络安全
The telnet port 3658 is used by process
是否在本地使用Arthas的时候,遇到The telnet port 3658 is used by process 34725 instead of target process 44848, you will connect to an unexpected process的异常,其实解决方法很简单。
1324 0
The telnet port 3658 is used by process
|
4月前
Error: listen EADDRINUSE: address already in use :::5000
Error: listen EADDRINUSE: address already in use :::5000
|
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
311 0
|
8月前
|
机器学习/深度学习 网络协议 决策智能
ubuntu16.04中 启动 Error starting userland proxy: listen tcp 0.0.0.0:5900: bind: address already in use
ubuntu16.04中 启动 Error starting userland proxy: listen tcp 0.0.0.0:5900: bind: address already in use
110 0
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
|
网络协议
TCP server
TCP server
75 0
|
网络协议 NoSQL Redis
Could not create server TCP listening socket 127.0.0.16379 bind 操作成功
Could not create server TCP listening socket 127.0.0.16379 bind 操作成功
Could not create server TCP listening socket 127.0.0.16379 bind 操作成功
|
网络协议 NoSQL Redis
Start_Redis Nov 21:11:04.422 # Creating Server TCP listening socket 127.0.0.1:6379: bind: No error
启动 redis-server.exe 报错19 Nov 21:11:04.422 # Creating Server TCP listening socket 127.0.0.1:6379: bind: No error
427 0
|
网络协议
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...
3054 0