Node.js net module server listen socket EPERM error

Today I was playing around with creating a REPL server in Node.js using a local socket (see the Node.js REPLify module┬áif that sounds interesting to you). I got stuck on a permission error when trying to create the REPL server. I eventually tracked it down to within the module, where it executes the “listen” method on a net server with a socket file location param. The weird part was that it failed with the same error even after I opened up the directory permissions to 777, and it even failed when I ran the script as superuser. Another weird behavior was that it worked just fine if I modified the module to listen on a network port instead of on a socket.

That last behavior led me to figure out the problem eventually. Apparently Node.js cannot create sockets on a shared directory in a virtual machine. When I changed the socket to a different directory, it seemed to work just fine with no permission errors.

I wanted to share this information because I couldn’t find it mentioned anywhere on the Internet when I was troubleshooting my problem. Hopefully this helps someone out there.