Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERR_SOCKET_BAD_PORT on Node.js #1118

Closed
2 tasks done
outhSerge opened this issue Jan 3, 2022 · 8 comments · Fixed by #1141
Closed
2 tasks done

ERR_SOCKET_BAD_PORT on Node.js #1118

outhSerge opened this issue Jan 3, 2022 · 8 comments · Fixed by #1141
Labels

Comments

@outhSerge
Copy link

⚠️ 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

@outhSerge outhSerge added the help label Jan 3, 2022
@louislam
Copy link
Owner

louislam commented 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.

@outhSerge
Copy link
Author

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
Copy link
Author

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

@chakflying
Copy link
Collaborator

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

@outhSerge
Copy link
Author

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
Copy link
Author

outhSerge commented 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
Copy link
Author

outhSerge commented 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.

@crustulumtheoneandonly
Copy link

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 up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants