klee
klee

Reputation: 1624

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

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?

Upvotes: 43

Views: 110122

Answers (5)

Mehmet Gökalp
Mehmet Gökalp

Reputation: 454

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

Upvotes: 10

Yilmaz
Yilmaz

Reputation: 49182

in ubuntu 18.04

  sudo nano /etc/redis/redis.conf

and change the port

enter image description here

Upvotes: 7

Jochem Schulenklopper
Jochem Schulenklopper

Reputation: 6914

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.

Upvotes: 79

Houssem Hichri
Houssem Hichri

Reputation: 25

-p <port> Server port (default: 6379).

So if your instance is running under port 1985 just run

$redis-cli -p 1985

Upvotes: 0

Itamar Haber
Itamar Haber

Reputation: 49932

  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).

Upvotes: 8

Related Questions