You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多
文档控制台
免费开始使用

修改Redis端口为6380后仍连接默认6379端口问题求助

Fixing Redis Connection Refusal to 127.0.0.1:6379 After Changing Port to 6380

Hey there! Let's troubleshoot why Redis is still clinging to the default 6379 port even after you updated it to 6380. Below are step-by-step fixes sorted by likelihood:

1. Ensure Your Redis Config File is Applied Correctly

This is the most common culprit. Here's what to do:

  • Locate your Redis config file (typically redis.conf on Linux, redis.windows.conf on Windows). Open it and confirm the line port 6380 exists without a leading # (which would comment it out).
  • Restart the Redis service to apply the new config:
    • On Linux with systemd: sudo systemctl restart redis
    • On Linux using the direct command: redis-server /path/to/your/redis.conf
    • On Windows: Stop the Redis service via Services or task manager, then restart it with the updated config file.
  • Verify Redis is listening on 6380:
    • Linux: Run netstat -tulpn | grep redis – you should see a line showing 127.0.0.1:6380 or 0.0.0.0:6380.
    • Windows: Run netstat -ano | findstr :6380 – check if there's a process ID associated with this port.

2. Update Your Client Connection Settings

If Redis is running on 6380 but your client still tries 6379, you need to adjust the client's config:

  • Redis CLI: Instead of just redis-cli, use redis-cli -p 6380 to explicitly specify the port.
  • Application Code: Check your app's Redis connection setup. For example:
    • Python (redis-py):
      import redis
      r = redis.Redis(host='127.0.0.1', port=6380, db=0)
      
    • Java (Jedis):
      Jedis jedis = new Jedis("127.0.0.1", 6380);
      
  • Environment Variables: If your app uses variables like REDIS_PORT, make sure it's set to 6380 instead of 6379.

3. Stop Any Stale Redis Instances

Sometimes the old 6379 instance keeps running in the background, causing confusion:

  • Linux: List all Redis processes with ps aux | grep redis-server, then kill the stale one with kill <process_id>.
  • Windows: Open Task Manager, find any redis-server.exe processes, and end them. Then restart Redis with your 6380 config.

4. Double-Check for Socket/Pipe Configs (Less Common)

If your Redis config uses Unix sockets (Linux) or named pipes (Windows) instead of TCP, clients might default to that. Confirm:

  • In redis.conf, check if unixsocket is enabled. If you want to use TCP port 6380, ensure this setting isn't overriding your port config, or update your client to use the socket path instead.

Start with the first two steps – they resolve 90% of this issue. If you still run into problems, feel free to share more details about your setup (OS, client type, etc.)!

内容的提问来源于stack exchange,提问作者Shaik

火山引擎 最新活动