How to start redis-server on a different port than the default port 6379 in ubuntu

59,523

Solution 1

redis-server --port 6380 will start a Redis server listening to port 6380.

redis-cli -p 6380 -- a suggestion made here as well -- does not start a Redis server listening to port 6380, but tries to connect the CLI to a (hopefully running) Redis server that listens to that port.

Solution 2

  1. Locate your redis.conf file (it will probably be at /etc/redis/6379.conf).
  2. Copy the file or edit that one and change the port directive to any free port.
  3. Start Redis with the new config file (note that if you've copied the file in the previous step, you'll need to change the service's startup script to use that file).

Solution 3

To create a development server on your local machine you can simply use

redis-server --port 6380

Another options:

#redis-server --help

Usage: ./redis-server [/path/to/redis.conf] [options]
       ./redis-server - (read config from stdin)
       ./redis-server -v or --version
       ./redis-server -h or --help
       ./redis-server --test-memory <megabytes>

Examples:
       ./redis-server (run the server with default conf)
       ./redis-server /etc/redis/6379.conf
       ./redis-server --port 7777
       ./redis-server --port 7777 --replicaof 127.0.0.1 8888
       ./redis-server /etc/myredis.conf --loglevel verbose

Solution 4

in ubuntu 18.04

  sudo nano /etc/redis/redis.conf

and change the port

enter image description here

Share:
59,523
klee
Author by

klee

Updated on November 10, 2021

Comments

  • klee
    klee over 2 years

    How to start redis-server on a different port than the default port 6379 in Ubuntu? I have used the following steps to install the redis:

    sudo add-apt-repository ppa:rwky/redis
    sudo apt-get update
    sudo apt-get -y install redis-server
    

    I installed it, but I don't know how to start redis-server on a different port than the default port 6379. So kindly tell me the steps to change the default port to different port?

  • Jochem Schulenklopper
    Jochem Schulenklopper about 6 years
    Unfortunately, this does not answer the question. redis-cli -p <port> tries to connect the CLI to a Redis server listening to that port. The question was how to start a Redis server listening on a different port.
  • AATHITH RAJENDRAN
    AATHITH RAJENDRAN almost 5 years
    With this cmd we can connect the CLI to already running Redis server in port 1985, but will not start redis server to listen in 1985.
  • AATHITH RAJENDRAN
    AATHITH RAJENDRAN almost 5 years
    I have one more question @Itamar, will that be a problem if I run 3 redis server in the same port on different machines(as master-slave)??
  • Jochem Schulenklopper
    Jochem Schulenklopper over 4 years
    Huh, @ChristianMatthew? The question was "How to start redis-server on a different port" so the answer "redis-server --port 6380 will start a Redis server listening to port 6380" is clear, concise and correct. The question wasn't "Why ..." asking for an explanation, but just how to do something.
  • Christian Matthew
    Christian Matthew over 4 years
    The proper way to handle the question is to edit the question that it can fit your symantic reasoning and provide a full answer. In the OP's post he explains that he needs to know "how to do it." > I installed, but I don't know how to how to start redis-server on a different port than the default port 6379 > So kindly tell me the steps to change the default port to different port ? Where it says please tell me the steps this would be the "why" Even though he is saying why. Also, for other people coming across the question it would be more beneficial to properly answer the ques
  • Jochem Schulenklopper
    Jochem Schulenklopper over 4 years
    Instead of remarking that my answer isn't the best explanation -- although it clearly answers the current question, without reading too much into the situation of the OP -- why don't you provide a better answer?
  • Jochem Schulenklopper
    Jochem Schulenklopper over 4 years
    "Where it says please tell me the steps this would be the why" is obviously false. The OP is clearly asking for how, as stated in the title and the question text.
  • Christian Matthew
    Christian Matthew over 4 years
    I was only offering a suggestion to you to make the answer better and more complete.