Raspberry pi cant listen to port 80 (express.js) - express

so I am using raspberry pi as web server and if I want to start express app there's an error:
events.js:291
throw er; // Unhandled 'error' event
^
Error: listen EACCES: permission denied 0.0.0.0:80
at Server.setupListenHandle [as _listen2] (net.js:1293:21)
at listenInCluster (net.js:1358:12)
at Server.listen (net.js:1444:7)
at Function.listen (/home/malinapi/Documents/node_modules/express/lib/application.js:635:24)
at Object.<anonymous> (/home/malinapi/Documents/app.js:9:5)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
Emitted 'error' event on Server instance at:
at emitErrorNT (net.js:1337:8)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
code: 'EACCES',
errno: 'EACCES',
syscall: 'listen',
address: '0.0.0.0',
port: 80
}
Raspberry pi: 4, model b

Any server listening on ports 1024 and below must initially be opened as root and not as an ordinary user. I'm guessing it is running as the user malinapi.
It is either that or you already have something running on port 80

Related

Unable to start new project generated by express-generator. Error: ENOENT: no such file or directory

So I created a git repo -> npm init -> running express-generator getting this error
well it's something related to the sass I guess
$end:DEBUG='src:*'; npm start
ObjectNotFound: Cannot find drive. A drive with the name 'end' does not exist.
> src#0.0.0 start
> node ./bin/www
internal/fs/utils.js:307
throw err;
^
Error: ENOENT: no such file or directory, scandir 'C:\Users\MegaMind\Projects\inventoryInExpress\src\node_modules\node-sass\vendor'
at Object.readdirSync (fs.js:1021:3)
at Object.getInstalledBinaries (C:\Users\MegaMind\Projects\inventoryInExpress\src\node_modules\node-sass\lib\extensions.js:133:13)
at foundBinariesList (C:\Users\MegaMind\Projects\inventoryInExpress\src\node_modules\node-sass\lib\errors.js:20:15)
at foundBinaries (C:\Users\MegaMind\Projects\inventoryInExpress\src\node_modules\node-sass\lib\errors.js:15:5)
at Object.module.exports.missingBinary (C:\Users\MegaMind\Projects\inventoryInExpress\src\node_modules\node-sass\lib\errors.js:45:5)
at module.exports (C:\Users\MegaMind\Projects\inventoryInExpress\src\node_modules\node-sass\lib\binding.js:15:30)
at Object.<anonymous> (C:\Users\MegaMind\Projects\inventoryInExpress\src\node_modules\node-sass\lib\index.js:14:35)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32) {
errno: -4058,
syscall: 'scandir',
code: 'ENOENT',
path: 'C:\\Users\\MegaMind\\Projects\\inventoryInExpress\\src\\node_modules\\node-sass\\vendor'
}

Cannot find module "postgraphile plugin upload field "

i installed postgraphile-plugin-upload-field
npm i graphile-contrib/postgraphile-plugin-upload-field
then
postgraphile -c 'postgres://postgres:mysecretpass#192.168.38.4:5432/gimapp' --cors -p 5001 --enhance-graphiql --host "0.0.0.0" -s messages,basic_auth,user --append-plugins #graphile/postgis,#graphile-contrib/pg-simplify-inflector,postgraphile-plugin-connection-filter,#graphile-contrib/postgraphile-plugin-upload-field --watch --no-ignore-indexes --jwt-token-identifier basic_auth.jwt_token --jwt-secret mysecretpass
throws exception like this.
Failed to load plugin '#graphile-contrib/postgraphile-plugin-upload-field'
/usr/lib/node_modules/postgraphile/build/postgraphile/cli.js:268
throw e;
^
Error: Cannot find module '#graphile-contrib/postgraphile-plugin-upload-field'
Require stack:
- /usr/lib/node_modules/postgraphile/build/postgraphile/cli.js
- /usr/lib/node_modules/postgraphile/cli.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:925:15)
at Function.Module._load (node:internal/modules/cjs/loader:769:27)
at Module.require (node:internal/modules/cjs/loader:997:19)
at require (node:internal/modules/cjs/helpers:92:18)
at /usr/lib/node_modules/postgraphile/build/postgraphile/cli.js:263:20
at Array.map (<anonymous>)
at loadPlugins (/usr/lib/node_modules/postgraphile/build/postgraphile/cli.js:255:18)
at Object.<anonymous> (/usr/lib/node_modules/postgraphile/build/postgraphile/cli.js:323:23)
at Module._compile (node:internal/modules/cjs/loader:1108:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/lib/node_modules/postgraphile/build/postgraphile/cli.js',
'/usr/lib/node_modules/postgraphile/cli.js'
]
}
and here is another situation if i remove #graphile-contrib
postgraphile -c 'postgres://postgres:mysecretpass#192.168.38.4:5432/gimapp' --cors -p 5001 --enhance-graphiql --host "0.0.0.0" -s messages,basic_auth,user --append-plugins #graphile/postgis,#graphile-contrib/pg-simplify-inflector,postgraphile-plugin-connection-filter,postgraphile-plugin-upload-field --watch --no-ignore-indexes --jwt-token-identifier basic_auth.jwt_token --jwt-secret mysecretpass
here is the error:
PostGraphile v4.10.0 server listening on port 5001 🚀
Recoverable error occurred; use envvar 'DEBUG="graphile-build:warn"' for full error (see: https://graphile.org/postgraphile/debugging )
> TypeError: Cannot read property 'filter' of undefined…
Recoverable error occurred; use envvar 'DEBUG="graphile-build:warn"' for full error (see: https://graphile.org/postgraphile/debugging )

Error: listen EADDRINUSE: address already in use :::3000 ..... I got this error please tell me the solution this

//code const express = require('express') const app = express() const server = require('http').Server(app) const io = require('socket.io')(server) const { v4: uuidv4 } = require('uuid')
app.set('view engine', 'ejs') app.use(express.static('public'))
app.get('/',(req, res) =>{ res.redirect(/${uuidv4()}) })
app.get('/:room', (req, res) =>{ res.render('room', {roomId: req.params.room }) })
io.on('connection',socket =>{ socket.on('join room',(roomId, userId) =>{ console.log(roomId,userId) }) })
server.listen(3000)
// Error
[nodemon] 2.0.4 [nodemon] to restart at any time, enter rs [nodemon]
watching path(s): . [nodemon] watching extensions: js,mjs,json
[nodemon] starting node server.js events.js:292 throw er; // Unhandled
'error' event ^
Error: listen EADDRINUSE: address already in use :::3000 at
Server.setupListenHandle [as _listen2] (net.js:1313:16) at
listenInCluster (net.js:1361:12) at Server.listen (net.js:1447:7) at
Object. (I:\Volume E\zoom-clone\server.js:25:8) at Module._compile
(internal/modules/cjs/loader.js:1138:30) at
Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32) at
Function.Module._load (internal/modules/cjs/loader.js:879:14) at
Function.executeUserEntryPoint [as runMain]
(internal/modules/run_main.js:71:12) at
internal/main/run_main_module.js:17:47 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: 3000 } [nodemon] app crashed - waiting for file changes
before starting...
This error means the 3000 port already in use, refer the below answer
How to fix Error: listen EADDRINUSE while using nodejs?
In my case, I started the application in debug mode, which was using the port 3000, after that I faced this issue. I resolved this issue by reboot, which is not a correct way. I recommends the above answer.

Failed to install redis-commander in debian strech

I tried to install redis-commander but when i run redis-commander i am getting the following errors
redis-commander
{ Error: ENOENT : no such file or directory, open '/root/.redis-commander'
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/root/.redis-commander' }
No config found or was invalid.
Using default configuration.
No Save: true
listening on 0.0.0.0 : 8081
events.js:137
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE 0.0.0.0:8081
at Object._errnoException (util.js:1003:13)
at _exceptionWithHostPort (util.js:1024:20)
at Server.setupListenHandle [as _listen2] (net.js:1366:14)
at listenInCluster (net.js:1407:12)
at doListen (net.js:1522:7)
at process._tickCallback (internal/process/next_tick.js:152:19)
root#debian:/home/midhun#
Means address (port) already in use by some other process

NodeJS+ Express + MySQL app not running on Openshift

I have a nodejs app that I could succesfully deploy but is not starting. I'm getting this error all the time, when I look on the log files:
Warning: connect.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and will not scale past a single process.
Tue Mar 29 2016 05:48:11 GMT-0400 (EDT): Node server started on 127.8.221.129:8080 ...
Server on port : 8080
Tue Mar 29 2016 05:48:11 GMT-0400 (EDT): Node server stopped.
/var/lib/openshift/56f90f110c1e663f390001df/app-root/runtime/repo/models/user.js:14
throw err;
^
Error: getaddrinfo ENOTFOUND mysql://127.8.221.130:3306/ mysql://127.8.221.130:3306/:3306
at errnoException (dns.js:26:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:77:26)
--------------------
at Protocol._enqueue (/var/lib/openshift/56f90f110c1e663f390001df/app-root/runtime/repo/node_modules/mysql/lib/protocol/Protocol.js:141:48)
at Protocol.handshake (/var/lib/openshift/56f90f110c1e663f390001df/app-root/runtime/repo/node_modules/mysql/lib/protocol/Protocol.js:52:41)
at Connection.connect (/var/lib/openshift/56f90f110c1e663f390001df/app-root/runtime/repo/node_modules/mysql/lib/Connection.js:123:18)
at Object.<anonymous> (/var/lib/openshift/56f90f110c1e663f390001df/app-root/runtime/repo/models/user.js:12:13)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/var/lib/openshift/56f90f110c1e663f390001df/app-root/runtime/repo/routes/users.js:3:13)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
This is MySQL connection code (password is hidden, but I use the one provided by the MySQL cartridge, as well as the user):
var connection = mysql.createConnection({
host : 'mysql://' + process.env.OPENSHIFT_MYSQL_DB_HOST + ':' + process.env.OPENSHIFT_MYSQL_DB_PORT + '/',
user : 'adminbL38x6k',
password : '********',
database : 'addressbook'
});
connection.connect( function(err){
if (err){
throw err;
}
else {
console.log('Connected');
}
});
I'm using PHPmyAdmin too, for creating tables/managing database. Any ideas? I'm pretty desperate... Thank you!
The connection error shows two connection strings (ENOTFOUND mysql://127.8.221.130:3306/ mysql://127.8.221.130:3306/:3306) and according to the mysql node.js driver's documentation, the host and port should be provided separately or in a single connection string, I recommend rather:
var connection = mysql.createConnection({
host : process.env.OPENSHIFT_MYSQL_DB_HOST,
port : process.env.OPENSHIFT_MYSQL_DB_PORT,
user : 'adminbL38x6k',
password : '********',
database : 'addressbook'
});
...or the connection string way:
var connection = mysql.createConnection(process.env.OPENSHIFT_MYSQL_DB_URL + 'addressbook');