Search code examples
javascriptnode.jsweb-servicestor

Failed to torify node application


I'm writing a simple node server, and trying to torify it. But I got the following error, any idea?

It works fine when I go without torsocks, and I used default config for tor daemon.

$ torsocks node server.js
[Jan 26 09:38:40] WARNING torsocks[30933]: [syscall] Unsupported syscall number 293. Denying the call (in tsocks_syscall() at syscall.c:465)
events.js:160
      throw er; // Unhandled 'error' event
      ^

Error: listen EPERM :::5000
    at Object.exports._errnoException (util.js:1022:11)
    at exports._exceptionWithHostPort (util.js:1045:20)
    at Server._listen2 (net.js:1259:14)
    at listen (net.js:1295:10)
    at Server.listen (net.js:1391:5)
    at Object.<anonymous> (/home/test/src/heroku/ruten-helper/server.js:10:8)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)

var http = require('http')

// Create server
var server = http.createServer(function (req, res) {
    console.log("client connected")
    res.end('HI!')
})

// Listen
server.listen(process.env.PORT || 5000)


Solution

  • I got it. I checked the torsocks debug message, I see the following.

    [listen] Non localhost inbound connection are not allowed. (in tsocks_listen() at listen.c:64)

    And I changed my code to listen on localhost only, problem resolved.