ERR_SOCKET_BAD_PORT on Node.js #707

Closed
opened 2026-02-28 01:55:20 -05:00 by deekerman · 8 comments
Owner

Originally created by @outhSerge on GitHub (Jan 3, 2022).

⚠️ Please verify that this bug has NOT been raised before.

  • I checked and didn't find similar issue

🛡️ Security Policy

📝 Describe your problem

Hello!
I installed it according to the instructions, but the application didn't open. In the logs:

Welcome to Uptime Kuma
Node Env: production
Importing Node libraries
Importing 3rd-party libraries
Importing this project modules
Prepare Notification Providers
Version: 1.11.1
Creating express and socket.io instance
Server Type: HTTP
Data Dir: ./data/
Connecting to the Database
SQLite config:
[ { journal_mode: 'wal' } ]
[ { cache_size: -12000 } ]
SQLite Version: 3.36.0
Connected
Your database version: 10
Latest database version: 10
Database patch not needed
Database Patch 2.0 Process
Load JWT secret from database.
No user, need setup
Adding route
Adding socket handler
Init the server
Trace: RangeError [ERR_SOCKET_BAD_PORT]: options.port should be >= 0 and < 65536. Received NaN.
at new NodeError (node:internal/errors:371:5)
at validatePort (node:internal/validators:216:11)
at Server.listen (node:net:1461:5)
at /home/lylab/swifty.support/monitor/server/server.js:1336:12 {
code: 'ERR_SOCKET_BAD_PORT'
}
at process. (/home/lylab/swifty.support/monitor/server/server.js:1542:13)
at process.emit (node:events:390:28)
at emit (node:internal/process/promises:136:22)
at processPromiseRejections (node:internal/process/promises:242:25)
at processTicksAndRejections (node:internal/process/task_queues:97:32)
If you keep encountering errors, please report to https://github.com/louislam/uptime-kuma/issues

I contacted support, they said that ports 3000 and 3001 are open.

What am I doing wrong, what could be the problem?
Thanks!

🐻 Uptime-Kuma Version

1.11.1

💻 Operating System and Arch

Linux web772.default-host.net 3.10.0-962.3.2.lve1.5.63.el7.x86_64 #1 SMP Fri Oct 8 12:03:35 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

🌐 Browser

Chrome, Version 96.0.4664.110 (Official Build) (64-bit)

🐋 Docker Version

No response

🟩 NodeJS Version

16.13.1 LTS

Originally created by @outhSerge on GitHub (Jan 3, 2022). ### ⚠️ Please verify that this bug has NOT been raised before. - [X] I checked and didn't find similar issue ### 🛡️ Security Policy - [X] I agree to have read this project [Security Policy](https://github.com/louislam/uptime-kuma/security/policy) ### 📝 Describe your problem Hello! I installed it according to the instructions, but the application didn't open. In the logs: > Welcome to Uptime Kuma Node Env: production Importing Node libraries Importing 3rd-party libraries Importing this project modules Prepare Notification Providers Version: 1.11.1 Creating express and socket.io instance Server Type: HTTP Data Dir: ./data/ Connecting to the Database SQLite config: [ { journal_mode: 'wal' } ] [ { cache_size: -12000 } ] SQLite Version: 3.36.0 Connected Your database version: 10 Latest database version: 10 Database patch not needed Database Patch 2.0 Process Load JWT secret from database. No user, need setup Adding route Adding socket handler Init the server Trace: RangeError [ERR_SOCKET_BAD_PORT]: options.port should be >= 0 and < 65536. Received NaN. at new NodeError (node:internal/errors:371:5) at validatePort (node:internal/validators:216:11) at Server.listen (node:net:1461:5) at /home/lylab/swifty.support/monitor/server/server.js:1336:12 { code: 'ERR_SOCKET_BAD_PORT' } at process.<anonymous> (/home/lylab/swifty.support/monitor/server/server.js:1542:13) at process.emit (node:events:390:28) at emit (node:internal/process/promises:136:22) at processPromiseRejections (node:internal/process/promises:242:25) at processTicksAndRejections (node:internal/process/task_queues:97:32) If you keep encountering errors, please report to https://github.com/louislam/uptime-kuma/issues I contacted support, they said that ports 3000 and 3001 are open. What am I doing wrong, what could be the problem? Thanks! ### 🐻 Uptime-Kuma Version 1.11.1 ### 💻 Operating System and Arch Linux web772.default-host.net 3.10.0-962.3.2.lve1.5.63.el7.x86_64 #1 SMP Fri Oct 8 12:03:35 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux ### 🌐 Browser Chrome, Version 96.0.4664.110 (Official Build) (64-bit) ### 🐋 Docker Version _No response_ ### 🟩 NodeJS Version 16.13.1 LTS
deekerman 2026-02-28 01:55:20 -05:00
  • closed this issue
  • added the
    help
    label
Author
Owner

@louislam commented on GitHub (Jan 3, 2022):

I guess there are some environment variables such as UPTIME_KUMA_PORT or PORT were set. You may have to check whether it is presented.

@louislam commented on GitHub (Jan 3, 2022): I guess there are some environment variables such as `UPTIME_KUMA_PORT` or `PORT` were set. You may have to check whether it is presented.
Author
Owner

@outhSerge commented on GitHub (Jan 3, 2022):

Ok, I'm searching through files:

UPTIME_KUMA_PORT

\server\server.js:
75 }
76
77: const port = parseInt(process.env.UPTIME_KUMA_PORT || process.env.PORT || args.port || 3001);
78
79 // SSL

\extra\healthcheck.js:
26 }
27
28: const port = parseInt(process.env.UPTIME_KUMA_PORT || process.env.PORT || 3001);
29
30 let options = {

PORT

\server\server.js:
75 }
76
77: const port = parseInt(process.env.UPTIME_KUMA_PORT || process.env.PORT || args.port || 3001);
78
79 // SSL
..
580 bean.hostname = monitor.hostname;
581 bean.maxretries = monitor.maxretries;
582: bean.port = monitor.port;
583 bean.keyword = monitor.keyword;
584 bean.ignoreTls = monitor.ignoreTls;

\extra\healthcheck.js:
26 }
27
28: const port = parseInt(process.env.UPTIME_KUMA_PORT || process.env.PORT || 3001);
29
30 let options = {

\extra\install.batsh:
24 }
25
26: defaultPort = "3001";
27
28 function checkNode() {

\install.sh:
20 "read" "-p" "Which installation method do you prefer? [DOCKER/local]: " "type"
21 fi
22: defaultPort="3001"
23 function checkNode {
24 local _0

One more point, perhaps this is important - I'm trying to install app on a subdomain - monitor.example.com

@outhSerge commented on GitHub (Jan 3, 2022): Ok, I'm searching through files: UPTIME_KUMA_PORT >\server\server.js: 75 } 76 77: const port = parseInt(process.env.UPTIME_KUMA_PORT || process.env.PORT || args.port || 3001); 78 79 // SSL >\extra\healthcheck.js: 26 } 27 28: const port = parseInt(process.env.UPTIME_KUMA_PORT || process.env.PORT || 3001); 29 30 let options = { PORT >\server\server.js: 75 } 76 77: const port = parseInt(process.env.UPTIME_KUMA_PORT || process.env.PORT || args.port || 3001); 78 79 // SSL .. 580 bean.hostname = monitor.hostname; 581 bean.maxretries = monitor.maxretries; 582: bean.port = monitor.port; 583 bean.keyword = monitor.keyword; 584 bean.ignoreTls = monitor.ignoreTls; >\extra\healthcheck.js: 26 } 27 28: const port = parseInt(process.env.UPTIME_KUMA_PORT || process.env.PORT || 3001); 29 30 let options = { >\extra\install.batsh: 24 } 25 26: defaultPort = "3001"; 27 28 function checkNode() { >\install.sh: 20 "read" "-p" "Which installation method do you prefer? [DOCKER/local]: " "type" 21 fi 22: defaultPort="3001" 23 function checkNode { 24 local _0 One more point, perhaps this is important - I'm trying to install app on a subdomain - monitor.example.com
Author
Owner

@outhSerge commented on GitHub (Jan 3, 2022):

If it helps to resolve this issue, I can provide any access.

@outhSerge commented on GitHub (Jan 3, 2022): If it helps to resolve this issue, I can provide any access.
Author
Owner

@chakflying commented on GitHub (Jan 3, 2022):

I think depending on your setup you can try to run it with an explicitly specified port:

UPTIME_KUMA_PORT=3001 node server/server.js
@chakflying commented on GitHub (Jan 3, 2022): I think depending on your setup you can try to run it with an explicitly specified port: ```shell UPTIME_KUMA_PORT=3001 node server/server.js ```
Author
Owner

@outhSerge commented on GitHub (Jan 4, 2022):

I added "UPTIME_KUMA_PORT=3001" to package.json like this:

"start-server": "UPTIME_KUMA_PORT=3001 node server/server.js",

and it solves ERR_SOCKET_BAD_PORT problem, but I still can't open the app - the page just get ERR_CONNECTION_TIMED_OUT and logs clear (without errors, just "Listening on 3001" at the end).

Anyway, thx a lot, my problem solved!

@outhSerge commented on GitHub (Jan 4, 2022): I added "UPTIME_KUMA_PORT=3001" to package.json like this: > "start-server": "UPTIME_KUMA_PORT=3001 node server/server.js", and it solves ERR_SOCKET_BAD_PORT problem, but I still can't open the app - the page just get ERR_CONNECTION_TIMED_OUT and logs clear (without errors, just "Listening on 3001" at the end). Anyway, thx a lot, my problem solved!
Author
Owner

@outhSerge commented on GitHub (Jan 4, 2022):

I tried to install the app on another domain but stil get timeout error...

-bash-4.2$ node server/server.js
Welcome to Uptime Kuma
Node Env: production
Importing Node libraries
Importing 3rd-party libraries
Importing this project modules
Prepare Notification Providers
Version: 1.11.1
Creating express and socket.io instance
Server Type: HTTP
Data Dir: ./data/
Connecting to the Database
SQLite config:
[ { journal_mode: 'wal' } ]
[ { cache_size: -12000 } ]
SQLite Version: 3.36.0
Connected
Your database version: 10
Latest database version: 10
Database patch not needed
Database Patch 2.0 Process
Load JWT secret from database.
No user, need setup
Adding route
Adding socket handler
Init the server
Listening on 3001

What can be wrong?

@outhSerge commented on GitHub (Jan 4, 2022): I tried to install the app on another domain but stil get timeout error... >-bash-4.2$ node server/server.js Welcome to Uptime Kuma Node Env: production Importing Node libraries Importing 3rd-party libraries Importing this project modules Prepare Notification Providers Version: 1.11.1 Creating express and socket.io instance Server Type: HTTP Data Dir: ./data/ Connecting to the Database SQLite config: [ { journal_mode: 'wal' } ] [ { cache_size: -12000 } ] SQLite Version: 3.36.0 Connected Your database version: 10 Latest database version: 10 Database patch not needed Database Patch 2.0 Process Load JWT secret from database. No user, need setup Adding route Adding socket handler Init the server Listening on 3001 What can be wrong?
Author
Owner

@outhSerge commented on GitHub (Jan 4, 2022):

Thx a lot again!
My problem with ERR_CONNECTION_TIMED_OUT was solved when I changed:

server/server.js

1337: server.listen(port, hostname, () => {

to

1337: server.listen('/home/accountname/.system/nodejs/www.domain.com.sock', () => {

*accountname and domain.com were changed, it's provided by my hoster.

And now it's working perfectly.

@outhSerge commented on GitHub (Jan 4, 2022): Thx a lot again! My problem with ERR_CONNECTION_TIMED_OUT was solved when I changed: server/server.js > 1337: server.listen(port, hostname, () => { to > 1337: server.listen('/home/accountname/.system/nodejs/www.domain.com.sock', () => { *accountname and domain.com were changed, it's provided by my hoster. And now it's working perfectly.
Author
Owner

@crustulumtheoneandonly commented on GitHub (Jun 21, 2022):

If anyone finds this when trying to spin up Uptime Kuma in kubernetes and is just starting out, my deployment.yaml looked like this with the missing env variable added:

(no guarantee)

.
.
.

    spec:
      containers:
        - image: louislam/uptime-kuma:latest
          name: uptiime-kuma
          ports:
            - containerPort: 3001
          **env:
            - name: UPTIME_KUMA_PORT
              value: "3001"**
          resources: {}

.
.
.

@crustulumtheoneandonly commented on GitHub (Jun 21, 2022): If anyone finds this when trying to spin up Uptime Kuma in kubernetes and is just starting out, my deployment.yaml looked like this with the missing env variable added: (no guarantee) . . . ``` spec: containers: - image: louislam/uptime-kuma:latest name: uptiime-kuma ports: - containerPort: 3001 **env: - name: UPTIME_KUMA_PORT value: "3001"** resources: {} ``` . . .
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/uptime-kuma#707
No description provided.