Issue with ( Bench Start ) Command (27.0.0.1:13000: bind: Address already in use)

Hello,

I successfully installed Frappe 15 on Ubuntu using the instructions from this link. After installation, I deleted the site from bench and created a new one on Frappe Bench. However, when I try to run bench start, I encounter the following problem:

Summary of the problem:

socket 127.0.0.1:13000: bind: Address already in use
socket 127.0.0.1:11000: bind: Address already in use

I’ve tried various solutions, including the method mentioned in the link below, but the issue persists:

cd frappe-bench
git clone https://github.com/proenterprise/bench-stop
mv ./bench-stop/stop.py .
sudo rm -r ./bench-stop

When I run bench start, I receive the following error:

Could not create server TCP listening socket 127.0.0.1:13000: bind: Address already in use
Could not create server TCP listening socket 127.0.0.1:11000: bind: Address already in use

If you are following those steps, you are only downloading the file and then copying it and deleting the original.

you have to run it using python3 stop.py if I remember correctly.

You have the information in the github repository

I ran it with Python 3 but still the problem is not solved

Try

sudo fuser -k 13000/tcp
sudo fuser -k 11000/tcp

yawar-frappe@yict:~/frappe-bench$ sudo fuser -k 13000/tcp
[sudo] password for yawar-frappe:
13000/tcp: 1202
yawar-frappe@yict:~/frappe-bench$ sudo fuser -k 11000/tcp
11000/tcp: 609
yawar-frappe@yict:~/frappe-bench$
yawar-frappe@yict:~/frappe-bench$ bench start
22:27:05 system | redis_cache.1 started (pid=10140)
22:27:05 system | redis_queue.1 started (pid=10143)
22:27:05 system | web.1 started (pid=10147)
22:27:05 redis_queue.1 | 10148:C 01 Feb 2024 22:27:05.676 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
22:27:05 redis_cache.1 | 10145:C 01 Feb 2024 22:27:05.676 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
22:27:05 redis_cache.1 | 10145:C 01 Feb 2024 22:27:05.676 # Redis version=6.0.16, bits=64, commit=00000000, modified=0, pid=10145, just started
22:27:05 redis_cache.1 | 10145:C 01 Feb 2024 22:27:05.676 # Configuration loaded
22:27:05 redis_queue.1 | 10148:C 01 Feb 2024 22:27:05.677 # Redis version=6.0.16, bits=64, commit=00000000, modified=0, pid=10148, just started
22:27:05 redis_queue.1 | 10148:C 01 Feb 2024 22:27:05.677 # Configuration loaded
22:27:05 redis_cache.1 | 10145:M 01 Feb 2024 22:27:05.677 * Increased maximum number of open files to 10032 (it was originally set to 1024).
22:27:05 redis_cache.1 | 10145:M 01 Feb 2024 22:27:05.677 # Could not create server TCP listening socket 127.0.0.1:13000: bind: Address already in use
22:27:05 redis_queue.1 | 10148:M 01 Feb 2024 22:27:05.678 * Increased maximum number of open files to 10032 (it was originally set to 1024).
22:27:05 redis_queue.1 | 10148:M 01 Feb 2024 22:27:05.678 # Could not create server TCP listening socket 127.0.0.1:11000: bind: Address already in use
22:27:05 system | redis_cache.1 stopped (rc=1)
22:27:05 system | redis_queue.1 stopped (rc=1)
22:27:05 system | schedule.1 started (pid=10154)
22:27:05 system | watch.1 started (pid=10156)
22:27:05 system | worker.1 started (pid=10153)
22:27:05 system | socketio.1 started (pid=10158)
22:27:05 system | sending SIGTERM to web.1 (pid 10147)
22:27:05 system | sending SIGTERM to socketio.1 (pid 10158)
22:27:05 system | sending SIGTERM to watch.1 (pid 10156)
22:27:05 system | sending SIGTERM to schedule.1 (pid 10154)
22:27:05 system | sending SIGTERM to worker.1 (pid 10153)
22:27:05 system | socketio.1 stopped (rc=-15)
22:27:05 system | watch.1 stopped (rc=-15)
22:27:05 system | worker.1 stopped (rc=-15)
22:27:05 system | web.1 stopped (rc=-15)
22:27:05 system | schedule.1 stopped (rc=-15)

sudo lsof -i :13000
sudo lsof -i :11000

sudo kill -9 PID (where PID is the PID obtained with the previous commands)

I ran this command and it runs again with the new PID

yawar-frappe@yict:~/frappe-bench$ sudo lsof -i :13000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
frappe-sc 11417 yawar-frappe 3u IPv4 964974993 0t0 TCP localhost:41018->localhost:13000 (ESTABLISHED)
redis-ser 11463 yawar-frappe 6u IPv4 964965579 0t0 TCP localhost:13000 (LISTEN)
redis-ser 11463 yawar-frappe 7u IPv4 964968046 0t0 TCP localhost:13000->localhost:41018 (ESTABLISHED)
yawar-frappe@yict:~/frappe-bench$ sudo lsof -i :11000
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
rq:worker 613 yawar-frappe 3u IPv4 963034189 0t0 TCP localhost:38368->localhost:11000 (ESTABLISHED)
rq:worker 614 yawar-frappe 3u IPv4 963014555 0t0 TCP localhost:38366->localhost:11000 (ESTABLISHED)
redis-ser 10115 yawar-frappe 6u IPv4 963030914 0t0 TCP localhost:11000 (LISTEN)
redis-ser 10115 yawar-frappe 7u IPv4 963030986 0t0 TCP localhost:11000->localhost:38366 (ESTABLISHED)
redis-ser 10115 yawar-frappe 8u IPv4 963030988 0t0 TCP localhost:11000->localhost:38368 (ESTABLISHED)
redis-ser 10115 yawar-frappe 9u IPv4 963012093 0t0 TCP localhost:11000->localhost:38384 (ESTABLISHED)
node 10120 yawar-frappe 20u IPv4 963036217 0t0 TCP localhost:38384->localhost:11000 (ESTABLISHED)
yawar-frappe@yict:~/frappe-bench$

More information :

Command :
bench start
Result :

yawar-frappe@yict:~/frappe-bench$ bench start
23:41:58 system        | redis_queue.1 started (pid=11593)
23:41:58 system        | redis_cache.1 started (pid=11598)
23:41:58 redis_queue.1 | 11596:C 01 Feb 2024 23:41:58.405 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
23:41:58 redis_queue.1 | 11596:C 01 Feb 2024 23:41:58.405 # Redis version=6.0.16, bits=64, commit=00000000, modified=0, pid=11596, just started
23:41:58 redis_queue.1 | 11596:C 01 Feb 2024 23:41:58.405 # Configuration loaded
23:41:58 redis_queue.1 | 11596:M 01 Feb 2024 23:41:58.406 * Increased maximum number of open files to 10032 (it was originally set to 1024).
23:41:58 system        | worker.1 started (pid=11602)
23:41:58 redis_queue.1 | 11596:M 01 Feb 2024 23:41:58.407 # Could not create server TCP listening socket 127.0.0.1:11000: bind: Address already in use
23:41:58 system        | redis_queue.1 stopped (rc=1)
23:41:58 redis_cache.1 | 11601:C 01 Feb 2024 23:41:58.410 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
23:41:58 redis_cache.1 | 11601:C 01 Feb 2024 23:41:58.410 # Redis version=6.0.16, bits=64, commit=00000000, modified=0, pid=11601, just started
23:41:58 redis_cache.1 | 11601:C 01 Feb 2024 23:41:58.410 # Configuration loaded
23:41:58 redis_cache.1 | 11601:M 01 Feb 2024 23:41:58.410 * Increased maximum number of open files to 10032 (it was originally set to 1024).
23:41:58 redis_cache.1 | 11601:M 01 Feb 2024 23:41:58.411 # Could not create server TCP listening socket 127.0.0.1:13000: bind: Address already in use
23:41:58 system        | redis_cache.1 stopped (rc=1)
23:41:58 system        | watch.1 started (pid=11606)
23:41:58 system        | web.1 started (pid=11608)
23:41:58 system        | socketio.1 started (pid=11607)
23:41:58 system        | schedule.1 started (pid=11603)
23:41:58 system        | sending SIGTERM to web.1 (pid 11608)
23:41:58 system        | sending SIGTERM to socketio.1 (pid 11607)
23:41:58 system        | sending SIGTERM to watch.1 (pid 11606)
23:41:58 system        | sending SIGTERM to schedule.1 (pid 11603)
23:41:58 system        | sending SIGTERM to worker.1 (pid 11602)
23:41:58 system        | web.1 stopped (rc=-15)
23:41:58 system        | watch.1 stopped (rc=-15)
23:41:58 system        | schedule.1 stopped (rc=-15)
23:41:58 system        | socketio.1 stopped (rc=-15)
23:41:58 system        | worker.1 stopped (rc=-15)

Command :
python3 stop.py
Result :

yawar-frappe@yict:~/frappe-bench$ sudo python3 stop.py 
11000/tcp:           11665
Port 12000 already closed
13000/tcp:           11687
9000/tcp:            11688
8000/tcp:              610   674   746   825   857   882   884   887   888   889   890   891
bench stopped
yawar-frappe@yict:~/frappe-bench$ python3 stop.py 
11000/tcp:           11752
Port 12000 already closed
13000/tcp:           11772
9000/tcp:            11773
8000/tcp:            11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734
bench stopped
yawar-frappe@yict:~/frappe-bench$ python stop.py 
11000/tcp:           11836
Port 12000 already closed
13000/tcp:           11854
9000/tcp:            11859
8000/tcp:            11817 11818 11819 11820 11821 11822 11823 11824 11825 11826 11827 11828
bench stopped
yawar-frappe@yict:~/frappe-bench$ python3 stop.py 
11000/tcp:           11911
Port 12000 already closed
13000/tcp:           11931
9000/tcp:            11936
8000/tcp:            11894 11895 11896 11897 11898 11899 11900 11901 11902 11903 11904 11905
bench stopped
yawar-frappe@yict:~/frappe-bench$ 

Command :
bench start

yawar-frappe@yict:~/frappe-bench$ bench start
23:47:36 system        | redis_cache.1 started (pid=12006)
23:47:36 system        | redis_queue.1 started (pid=12010)
23:47:36 system        | web.1 started (pid=12012)
23:47:36 redis_cache.1 | 12011:C 01 Feb 2024 23:47:36.582 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
23:47:36 redis_cache.1 | 12011:C 01 Feb 2024 23:47:36.582 # Redis version=6.0.16, bits=64, commit=00000000, modified=0, pid=12011, just started
23:47:36 redis_cache.1 | 12011:C 01 Feb 2024 23:47:36.582 # Configuration loaded
23:47:36 redis_queue.1 | 12016:C 01 Feb 2024 23:47:36.583 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
23:47:36 redis_queue.1 | 12016:C 01 Feb 2024 23:47:36.583 # Redis version=6.0.16, bits=64, commit=00000000, modified=0, pid=12016, just started
23:47:36 redis_queue.1 | 12016:C 01 Feb 2024 23:47:36.583 # Configuration loaded
23:47:36 redis_cache.1 | 12011:M 01 Feb 2024 23:47:36.583 * Increased maximum number of open files to 10032 (it was originally set to 1024).
23:47:36 redis_cache.1 | 12011:M 01 Feb 2024 23:47:36.583 # Could not create server TCP listening socket 127.0.0.1:13000: bind: Address already in use
23:47:36 redis_queue.1 | 12016:M 01 Feb 2024 23:47:36.584 * Increased maximum number of open files to 10032 (it was originally set to 1024).
23:47:36 redis_queue.1 | 12016:M 01 Feb 2024 23:47:36.584 # Could not create server TCP listening socket 127.0.0.1:11000: bind: Address already in use
23:47:36 system        | redis_cache.1 stopped (rc=1)
23:47:36 system        | redis_queue.1 stopped (rc=1)
23:47:36 system        | watch.1 started (pid=12021)
23:47:36 system        | socketio.1 started (pid=12024)
23:47:36 system        | worker.1 started (pid=12019)
23:47:36 system        | schedule.1 started (pid=12020)
23:47:36 system        | sending SIGTERM to web.1 (pid 12012)
23:47:36 system        | sending SIGTERM to socketio.1 (pid 12024)
23:47:36 system        | sending SIGTERM to watch.1 (pid 12021)
23:47:36 system        | sending SIGTERM to schedule.1 (pid 12020)
23:47:36 system        | sending SIGTERM to worker.1 (pid 12019)
23:47:36 system        | worker.1 stopped (rc=-15)
23:47:36 system        | socketio.1 stopped (rc=-15)
23:47:36 system        | web.1 stopped (rc=-15)
23:47:36 system        | schedule.1 stopped (rc=-15)
23:47:36 system        | watch.1 stopped (rc=-15)
yawar-frappe@yict:~/frappe-bench$ 

File : nginx.conf

yawar-frappe@yict:~/frappe-bench/config$ cat nginx.conf 
upstream frappe-bench-frappe {
        server 127.0.0.1:8000 fail_timeout=0;
}

upstream frappe-bench-socketio-server {
        server 127.0.0.1:9000 fail_timeout=0;
}



# setup maps


# server blocks





server {

        listen 8000;
        listen [::]:8000;


        server_name
                yawarerp.com
                ;

        root /home/yawar-frappe/frappe-bench/sites;



        proxy_buffer_size 128k;
        proxy_buffers 4 256k;
        proxy_busy_buffers_size 256k;



        add_header X-Frame-Options "SAMEORIGIN";
        add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload";
        add_header X-Content-Type-Options nosniff;
        add_header X-XSS-Protection "1; mode=block";
        add_header Referrer-Policy "same-origin, strict-origin-when-cross-origin";

        location /assets {
                try_files $uri =404;
                add_header Cache-Control "max-age=31536000";
        }

        location ~ ^/protected/(.*) {
                internal;
                try_files /yawarerp.com/$1 =404;
        }

        location /socket.io {
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_set_header X-Frappe-Site-Name yawarerp.com;
                proxy_set_header Origin $scheme://$http_host;
                proxy_set_header Host $host;

                proxy_pass http://frappe-bench-socketio-server;
        }

        location / {

                rewrite ^(.+)/$ $1 permanent;
                rewrite ^(.+)/index\.html$ $1 permanent;
                rewrite ^(.+)\.html$ $1 permanent;

                location ~* ^/files/.*.(htm|html|svg|xml) {
                        add_header Content-disposition "attachment";
                        try_files /yawarerp.com/public/$uri @webserver;
                }

                try_files /yawarerp.com/public/$uri @webserver;
        }

        location @webserver {
                proxy_http_version 1.1;
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header X-Frappe-Site-Name yawarerp.com;
                proxy_set_header Host $host;
                proxy_set_header X-Use-X-Accel-Redirect True;
                proxy_read_timeout 120;
                proxy_redirect off;

                proxy_pass  http://frappe-bench-frappe;
        }

        # error pages
        error_page 502 /502.html;
        location /502.html {
                root /home/yawar-frappe/.local/lib/python3.10/site-packages/bench/config/templates;
                internal;
        }

        access_log  /var/log/nginx/access.log main;
        error_log  /var/log/nginx/error.log;

        # optimizations
        sendfile on;
        keepalive_timeout 15;
        client_max_body_size 50m;
        client_body_buffer_size 16K;
        client_header_buffer_size 1k;

        # enable gzip compresion
        # based on https://mattstauffer.co/blog/enabling-gzip-on-nginx-servers-including-laravel-forge
        gzip on;
        gzip_http_version 1.1;
        gzip_comp_level 5;
        gzip_min_length 256;
        gzip_proxied any;
        gzip_vary on;
        gzip_types
                application/atom+xml
                application/javascript
                application/json
                application/rss+xml
                application/vnd.ms-fontobject
                application/x-font-ttf
                application/font-woff
                application/x-web-app-manifest+json
                application/xhtml+xml
                application/xml
                font/opentype
                image/svg+xml
                image/x-icon
                text/css
                text/plain
                text/x-component
                ;
                # text/html is always compressed by HttpGzipModule
}

File :redis_cache.conf

dbfilename redis_cache.rdb
dir /home/yawar-frappe/frappe-bench/config/pids
pidfile /home/yawar-frappe/frappe-bench/config/pids/redis_cache.pid
bind 127.0.0.1
port 13000
maxmemory 307mb
maxmemory-policy allkeys-lru
appendonly no

save ""


aclfile /home/yawar-frappe/frappe-bench/config/redis_cache.acl

File :redis_queue.conf

dbfilename redis_queue.rdb
dir /home/yawar-frappe/frappe-bench/config/pids
pidfile /home/yawar-frappe/frappe-bench/config/pids/redis_queue.pid
bind 127.0.0.1
port 11000

aclfile /home/yawar-frappe/frappe-bench/config/redis_queue.acl

File : /frappe-bench/Procfile

redis_cache: redis-server config/redis_cache.conf
redis_queue: redis-server config/redis_queue.conf

web: bench serve --port 8000

socketio: /home/yawar-frappe/.nvm/versions/node/v18.19.0/bin/node apps/frappe/socketio.js

watch: bench watch

schedule: bench schedule
worker: bench worker 1>> logs/worker.log 2>> logs/worker.error.log

File : /frappe-bench/sites$ cat common_site_config.json

{
 "background_workers": 1,
 "default_site": "yawarerp.com",
 "file_watcher_port": 6787,
 "frappe_user": "yawar-frappe",
 "gunicorn_workers": 11,
 "live_reload": true,
 "maintenance_mode": 0,
 "pause_scheduler": 0,
 "rebase_on_pull": false,
 "redis_cache": "redis://127.0.0.1:13000",
 "redis_queue": "redis://127.0.0.1:11000",
 "redis_socketio": "redis://127.0.0.1:13000",
 "restart_systemd_on_update": false,
 "serve_default_site": true,
 "shallow_clone": true,
 "socketio_port": 9000,
 "use_redis_auth": false,
 "webserver_port": 8000

An nginx.conf file? are you in production mode? because if so it is logical that bench start does not work

I had switched to production mode to solve the problem and the problem was not solved, so I switched to development mode again

sudo supervisorctl stop all
sudo systemctl stop nginx

thanks ,
The problem was solved and the bench was started

1 Like