Getting Error of Unhandled 'error' event events.js Angular 6 - node.js

I am new to angular and trying to setup an existing project on the server. I have setup the project on the root of the server and moved my build to apache folder (/var/www/html). I have a carousel on the home page and getting errors of main.da2430b946ec091e1c9e.js:1 ERROR TypeError: Cannot read property 'toArray' of undefined. I am using bootstrap carousel on home page.
When i run the command node project.js which have the NPM PACKAGES API ROUTES ADMIN ROUTES defined, i am getting error:
events.js:183
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE :::8081
at Server.setupListenHandle [as _listen2] (net.js:1360:14)
at listenInCluster (net.js:1401:12)
at Server.listen (net.js:1485:7)
at Object.<anonymous> (/home/sam/server/routes/chat.js:36:8)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/sam/server/routes/api.js:26:18)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
I read somewhere that this error might be because of the port being used by other service. So i run below comands:
sudo lsof -i :80 # checks port 81
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
apache2 886 sam 4u IPv6 18050 0t0 TCP *:http (LISTEN)
apache2 2559 www-data 4u IPv6 18050 0t0 TCP *:http (LISTEN)
apache2 2588 www-data 4u IPv6 18050 0t0 TCP *:http (LISTEN)
sudo lsof -i :80 # checks port 80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
apache2 886 sam 4u IPv6 18050 0t0 TCP *:http (LISTEN)
apache2 2559 www-data 4u IPv6 18050 0t0 TCP *:http (LISTEN)
apache2 2588 www-data 4u IPv6 18050 0t0 TCP *:http (LISTEN)
sudo lsof -i :8081 # checks port 80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 8468 sam 10u IPv6 54277 0t0 TCP *:tproxy (LISTEN)
sudo lsof -i :8081 # checks port 8081
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
node 8468 sam 10u IPv6 54277 0t0 TCP *:tproxy (LISTEN)
Here is the Angular version details:
Angular CLI: 6.0.8
Node: 8.14.0
OS: linux x64
Angular: 6.0.9
Can anyone help me with this issue. I have spend many hours on it and didn't found any working solution.
Thanks in Advance.

Related

Is Cassandra 4.1 not compatible with Ubuntu 20.04?

I can't make connection into my nodecluster, my nodetool status is currenty refused, i am using Cassandra 4.1 but not working trying edit in cassandra.yaml for localhost using 127.0.0.1 also edit my cassandra-env.sh for public name rename it with localhost too is also not working, so i decided to downgrade into 4.0.7 and working perfectly nothing to change into parameter of cassandra.yaml also cassandra-env.sh
Tools
Cassandra 4.1
Operating system : Ubuntu 20.04
Java version : openjdk version "11.0.17" 2022-10-18 OpenJDK Runtime
Environment (build 11.0.17+8-post-Ubuntu-1ubuntu220.04) OpenJDK
64-Bit Server VM (build 11.0.17+8-post-Ubuntu-1ubuntu220.04, mixed
mode)
here the code error in my nodetool status
root#myserver:/etc/cassandra# nodetool status
nodetool: Failed to connect to '127.0.0.1:7199' - ConnectException: 'Connection refused (Connection refused)'.
also in my cqlsh not working, only show like this
root#myserver:/etc/cassandra# cqlsh 161.97.96.126 9042
Connection error: ('Unable to connect to any servers', {'161.97.96.126:9042': ConnectionRefusedError(111, "Tried connecting to [('161.97.96.126', 9042)]. Last error: Connection refused")})
i was desperate, but try to install another version means downgrade from 4.1 to 4.0.7 (i make purge remove all my cassandra 4.1 file, installing from the beginning for 4.0.7), then viola nothing to change for the parameter in cassandra.yaml also cassandra-env.sh but works perfectly with my current tools above
Is Cassandra 4.1 is still not compatible with Ubuntu 20.04?
update 23-01-2023 22:10 pm
here my code when i try again installing cassandra 4.1 without edit anything, just fresh install again
root#myvps:~# sudo service cassandra status
● cassandra.service - LSB: distributed storage system for structured data
Loaded: loaded (/etc/init.d/cassandra; generated)
Active: active (running) since Mon 2023-01-23 14:49:41 CET; 8s ago
Docs: man:systemd-sysv-generator(8)
Process: 1644739 ExecStart=/etc/init.d/cassandra start (code=exited, status=0/SUCCESS)
Tasks: 24 (limit: 9479)
Memory: 2.2G
CGroup: /system.slice/cassandra.service
└─1644848 /usr/bin/java -ea -da:net.openhft... -XX:+UseThreadPriorities -XX:+HeapDumpOnOutOfMemoryError -X>
Jan 23 14:49:41 myvps.contaboserver.net systemd[1]: Starting LSB: distributed storage system for structured data...
Jan 23 14:49:41 myvps.contaboserver.net systemd[1]: Started LSB: distributed storage system for structured data.
root#myvps:~# sudo service cassandra status
● cassandra.service - LSB: distributed storage system for structured data
Loaded: loaded (/etc/init.d/cassandra; generated)
Active: active (exited) since Mon 2023-01-23 14:49:41 CET; 31s ago
Docs: man:systemd-sysv-generator(8)
Process: 1644739 ExecStart=/etc/init.d/cassandra start (code=exited, status=0/SUCCESS)
Jan 23 14:49:41 myvps.contaboserver.net systemd[1]: Starting LSB: distributed storage system for structured data...
Jan 23 14:49:41 myvps.contaboserver.net systemd[1]: Started LSB: distributed storage system for structured data.
root#myvps:~# nodetool version
nodetool: Failed to connect to '127.0.0.1:7199' - ConnectException: 'Connection refused (Connection refused)'.
root#myvps:~# cqlsh
Connection error: ('Unable to connect to any servers', {'127.0.0.1:9042': ConnectionRefusedError(111, "Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused")})
Update 23-01-2023 22:16 PM
i try accessing 2 thing
netstat -tnlp and show this
root#myvps:~# netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 537/redis-server 12
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 598/nginx: master p
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 447/systemd-resolve
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 534/sshd: /usr/sbin
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 578/postgres
tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 598/nginx: master p
tcp6 0 0 ::1:6379 :::* LISTEN 537/redis-server 12
tcp6 0 0 :::80 :::* LISTEN 598/nginx: master p
tcp6 0 0 :::22 :::* LISTEN 534/sshd: /usr/sbin
tcp6 0 0 ::1:5432 :::* LISTEN 578/postgres
tcp6 0 0 :::443 :::* LISTEN 598/nginx: master p
and also type sudo lsof -nPi -sTCP:LISTEN will show this
root#myvps:~# sudo lsof -nPi -sTCP:LISTEN
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
systemd-r 447 systemd-resolve 13u IPv4 18529 0t0 TCP 127.0.0.53:53 (LISTEN)
sshd 534 root 3u IPv4 18387 0t0 TCP *:22 (LISTEN)
sshd 534 root 4u IPv6 18389 0t0 TCP *:22 (LISTEN)
redis-ser 537 redis 6u IPv4 20184 0t0 TCP 127.0.0.1:6379 (LISTEN)
redis-ser 537 redis 7u IPv6 20185 0t0 TCP [::1]:6379 (LISTEN)
postgres 578 postgres 5u IPv6 20704 0t0 TCP [::1]:5432 (LISTEN)
postgres 578 postgres 6u IPv4 20705 0t0 TCP 127.0.0.1:5432 (LISTEN)
nginx 598 root 6u IPv6 18878 0t0 TCP *:443 (LISTEN)
nginx 598 root 7u IPv4 18879 0t0 TCP *:443 (LISTEN)
nginx 598 root 8u IPv4 18880 0t0 TCP *:80 (LISTEN)
nginx 598 root 9u IPv6 18881 0t0 TCP *:80 (LISTEN)
nginx 601 www-data 6u IPv6 18878 0t0 TCP *:443 (LISTEN)
nginx 601 www-data 7u IPv4 18879 0t0 TCP *:443 (LISTEN)
nginx 601 www-data 8u IPv4 18880 0t0 TCP *:80 (LISTEN)
nginx 601 www-data 9u IPv6 18881 0t0 TCP *:80 (LISTEN)
nginx 602 www-data 6u IPv6 18878 0t0 TCP *:443 (LISTEN)
nginx 602 www-data 7u IPv4 18879 0t0 TCP *:443 (LISTEN)
nginx 602 www-data 8u IPv4 18880 0t0 TCP *:80 (LISTEN)
nginx 602 www-data 9u IPv6 18881 0t0 TCP *:80 (LISTEN)
nginx 603 www-data 6u IPv6 18878 0t0 TCP *:443 (LISTEN)
nginx 603 www-data 7u IPv4 18879 0t0 TCP *:443 (LISTEN)
nginx 603 www-data 8u IPv4 18880 0t0 TCP *:80 (LISTEN)
nginx 603 www-data 9u IPv6 18881 0t0 TCP *:80 (LISTEN)
nginx 604 www-data 6u IPv6 18878 0t0 TCP *:443 (LISTEN)
nginx 604 www-data 7u IPv4 18879 0t0 TCP *:443 (LISTEN)
nginx 604 www-data 8u IPv4 18880 0t0 TCP *:80 (LISTEN)
nginx 604 www-data 9u IPv6 18881 0t0 TCP *:80 (LISTEN)
I can confirm that Cassandra 4.1 works on the latest versions of Ubuntu including 20.04 LTS and 22.04 LTS.
I didn't run into any issues installing/running Cassandra 4.1 out-of-the-box. You didn't specify the steps to replicate the problem so I'm assuming all you've done is perform a fresh installation of Cassandra 4.1. In any case, I followed the Installing Cassandra instructions documented in the official website and it just worked.
For what it's worth, I installed the same version of Java 11 as you:
openjdk version "11.0.17" 2022-10-18
Zero config change
After installing Cassandra 4.1 with NO configuration changes, I am able to run nodetool commands as expected:
$ nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 127.0.0.1 104.37 KiB 16 100.0% 0a7969a9-0d00-42f1-a574-87dfde5e3e7d rack1
$ nodetool version
ReleaseVersion: 4.1.0
I am also able to connect to the cluster with cqlsh:
Connected to Test Cluster at 127.0.0.1:9042
[cqlsh 6.1.0 | Cassandra 4.1.0 | CQL spec 3.4.6 | Native protocol v5]
Use HELP for help.
cqlsh>
Configure IP addresses
In an attempt to replicate what you did, I updated cassandra.yaml with the IP address of my test machine:
seed_provider:
- class_name: org.apache.cassandra.locator.SimpleSeedProvider
parameters:
- seeds: "10.1.2.3:7000"
listen_address: 10.1.2.3
rpc_address: 10.1.2.3
After starting Cassandra, I am again able to run nodetool commands as expected:
$ nodetool status
Datacenter: datacenter1
=======================
Status=Up/Down
|/ State=Normal/Leaving/Joining/Moving
-- Address Load Tokens Owns (effective) Host ID Rack
UN 10.1.2.3 136 KiB 16 100.0% 0a7969a9-0d00-42f1-a574-87dfde5e3e7d rack1
I am also able to connect to the cluster with cqlsh:
$ cqlsh 10.1.2.3
Connected to Test Cluster at 10.1.2.3:9042
[cqlsh 6.1.0 | Cassandra 4.1.0 | CQL spec 3.4.6 | Native protocol v5]
Use HELP for help.
cqlsh>
Conclusion
The most likely reason you're not able to connect to your cluster is that Cassandra is not running on the node. You can easily verify it with Linux utilities like lsof and netstat:
$ sudo lsof -nPi -sTCP:LISTEN
$ netstat -tnlp
You will need to check the Cassandra system.log for clues as to why is it is not running.
If you specified an IP address in listen_address, make sure that you also update the seeds list with the same IP address otherwise Cassandra will shutdown because it is unable to gossip with the seeds. Cheers!
👉 Please support the Apache Cassandra community by hovering over the cassandra tag then click on the Watch tag button. 🙏 Thanks!

Vue npm run serve Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH

I get:
Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH chunk-vendors.js:1
in Google Chrome console and blank page when trying to load Vue development page started via:
user#ubuntu:~# npm run serve
DONE Compiled successfully in 11909ms
App running at:
- Local: http://(my_public_ip):5008/
- Network: http://(my_public_ip):5008/
Note that the development build is not optimized.
To create a production build, run npm run build.
What I have tried up to now:
1.
sudo npm install -g n
sudo n 7.0
// also remember to update npm
sudo npm update -g npm
sudo npm cache clean -force
npm cache verify
sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node* ~/.npm
sudo rm -rf /usr/local/lib/node*
sudo rm -rf /usr/local/bin/node*
sudo rm -rf /usr/local/include/node*
sudo apt-get purge nodejs npm
sudo apt autoremove
sudo apt-get install npm nodejs
Tried to load the page in incognito mode (with no cache)
Nothing worked for me.
Everything was working great a few weeks ago. No settings have been changed. Nothing global installed or removed on the server.
lsof result is:
root#ubuntu:~# sudo lsof -i -P -n | grep LISTEN
systemd-r 855 systemd-resolve 13u IPv4 22732 0t0 TCP 127.0.0.53:53 (LISTEN)
sshd 935 root 3u IPv4 24127 0t0 TCP *:22 (LISTEN)
sshd 935 root 4u IPv6 24129 0t0 TCP *:22 (LISTEN)
nginx 940 root 6u IPv4 25804 0t0 TCP *:5001 (LISTEN)
nginx 940 root 7u IPv4 25805 0t0 TCP *:80 (LISTEN)
nginx 940 root 8u IPv6 25806 0t0 TCP *:80 (LISTEN)
nginx 942 www-data 6u IPv4 25804 0t0 TCP *:5001 (LISTEN)
nginx 942 www-data 7u IPv4 25805 0t0 TCP *:80 (LISTEN)
nginx 942 www-data 8u IPv6 25806 0t0 TCP *:80 (LISTEN)
nginx 943 www-data 6u IPv4 25804 0t0 TCP *:5001 (LISTEN)
nginx 943 www-data 7u IPv4 25805 0t0 TCP *:80 (LISTEN)
nginx 943 www-data 8u IPv6 25806 0t0 TCP *:80 (LISTEN)
postgres 992 postgres 3u IPv4 24408 0t0 TCP 127.0.0.1:5432 (LISTEN)
node 25318 user 19u IPv4 153059 0t0 TCP (my_public_ip):5008 (LISTEN)
Any ideas?
It's related to a timeout error that can be solved using this setup
On the file: vue.config.js
module.exports = {
devServer: {
proxy: {
'/*': {
target: 'http://localhost:8080',
secure: false,
prependPath: false,
proxyTimeout: 1000 * 60 * 10,
timeout: 1000 * 60 * 10
}
}
}
}
It was solved by itself. I came back to it after a day and it worked like it used to work.
I have no idea what was the reason.

node running server throw Error regarding already runinng port

Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1340:8)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
code: 'EADDRINUSE',
errno: 'EADDRINUSE',
syscall: 'listen',
address: '::',
port: 8082
}
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::8082
First findout your processID for your running process
lsof -i:1234(your port ID)
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Google 55523 ssurisettii 42u IPv6 0x53ab9cb514809733 0t0 TCP localhost:53991->localhost:us-cli (CLOSE_WAIT)
Google 55523 ssurisettii 45u IPv6 0x53ab9cb51480d473 0t0 TCP localhost:53989->localhost:us-cli (CLOSE_WAIT)
Google 55523 ssurisettii 46u IPv6 0x53ab9cb514809d53 0t0 TCP localhost:53990->localhost:us-cli (CLOSE_WAIT)
this ways shows,
Now you kill the your related processID
suppose your port id contains processID 1234
then **** kill -9 1234 ***

How can I start a NodeJS in the background?

I tried to start a project
node index.js , I got this
events.js:173
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::3000
at Server.setupListenHandle [as _listen2] (net.js:1255:14)
at listenInCluster (net.js:1303:12)
at Server.listen (net.js:1391:7)
at Function.listen (/home/forge/bheng/public/ios-base-api/node_modules/express/lib/application.js:618:24)
at Object.<anonymous> (/home/forge/bheng/public/ios-base-api/index.js:156:5)
at Module._compile (internal/modules/cjs/loader.js:721:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
Emitted 'error' event at:
at emitErrorNT (net.js:1282:8)
at internalTickCallback (internal/process/next_tick.js:72:19)
at process._tickCallback (internal/process/next_tick.js:47:5)
at Function.Module.runMain (internal/modules/cjs/loader.js:777:11)
at executeUserCode (internal/bootstrap/node.js:342:17)
at startExecution (internal/bootstrap/node.js:276:5)
at startup (internal/bootstrap/node.js:227:5)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
Then, I ran lsof -i | grep 3000, I got
node 6159 root 19u IPv6 58371978 0t0 TCP *:3000 (LISTEN)
Then, I ran ps -aux | grep node, I got
root 448 0.0 1.4 569912 29600 ? Ssl 21:21 0:00 node /usr/bin/pm2 update
root 1266 0.0 1.5 569400 31628 ? Ssl 21:28 0:00 node /usr/bin/pm2 update
root 6159 1.0 2.4 845540 49568 ? Ssl 21:46 0:02 node /home/forge/bheng/public/ios-base-api/index.js
root 6482 0.0 0.0 11244 948 pts/3 S+ 21:50 0:00 grep --color=auto node
root 32233 0.0 1.4 569912 29876 ? Ssl 21:14 0:00 node /usr/bin/pm2 update
I just want to start my nodejs app in the background and be able to access my endpoint anytime.
Why is this so complicated ? 😭
There are many packages which can help you. Check out pm2, forever
Both of them allow you to run your project in background and auto-reload is possible too :)

Error: listen EADDRINUSE :::443 error when trying to start nodejs server

I am trying to create a nodejs application that uses SSL. I have the cert, domain, and nodejs configured and working, but I'm having a problem sometimes when I stop my node server using Ctrl+C. I am getting the following error when trying to restart the node server:
Error: listen EADDRINUSE :::443
at Object.exports._errnoException (util.js:870:11)
at exports._exceptionWithHostPort (util.js:893:20)
at Server._listen2 (net.js:1237:14)
at listen (net.js:1273:10)
at Server.listen (net.js:1369:5)
at Object.<anonymous> (/var/www/html/server.js:212:47)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
Now I know this means that the port is in use, but I've tried several things to find the process that is using that port but I cant. A couple thing I've tried that are worth mentioning are netstat:
$ sudo netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1164/sshd
tcp6 0 0 :::22 :::* LISTEN 1164/sshd
udp 0 0 0.0.0.0:68 0.0.0.0:* 882/dhclient
and ps:
$ ps aux |grep node
ubuntu 7632 0.0 0.0 12944 988 pts/0 S+ 23:30 0:00 grep --color=auto node
but neither of them show me what is using port 443. I have pm2 to keep my node server in a running state, but it keeps saying errored and then I find the EADDRINUSE errors in the pm2 error log. I've been banging my head against the wall for hours. Can anyone assist me? Thanks!
I had this issue and the only command that revealed the process was
sudo lsof -iTCP -sTCP:LISTEN -P

Resources