I'm trying to build up a node but I'm having trouble syncing with the blockchain (really slow), and while it is syncing I'm testing the connection for my script that would be connected via IPC to the node when it will be synced. The problem I'm facing is that while I can connect to the node with "geth attach geth.ipc" from console, I can't do it from script, using web3.js library.

This is what I'm doing to test the connection:

const Web3 = require('web3');
const net = require('net');

var web3 = new Web3(new Web3.providers.IpcProvider('/.../node/geth.ipc', net));

   .then(() => console.log('is connected'))
   .catch(e => console.log(e));

This is always giving me the error: "Error: CONNECTION ERROR: Couldn't connect to node on IPC."

Is this error caused by the node still not synced or I'm doing something wrong? What I don't understand is that the IPC connection is actually open, so it doesn't really make sense that it's not connecting.

1 Answer 1


I had the same behavior from my local eth node (geth 1.10). Realized this was actually a permission issue as my geth is ran as a service from the root account whereas my script was triggered from ubuntu user.

See below my right accesses in my datadir

ubuntu@mymachine:~$ ls -al /var/cache/blockchain/
total 36
drwxr-xr-x  5 root root  4096 Jan 29 08:24 .
drwxr-xr-x 14 root root  4096 Jan 29 09:04 ..
drwx------  6 root root  4096 Jan 29 09:24 geth
srw-------  1 root root     0 Jan 29 08:24 geth.ipc
-rw-------  1 root root  2571 Jan 29 09:28 history
drwx------  2 root root  4096 Jan 28 21:28 keystore
drwx------  2 root root 16384 Jan 28 21:27 lost+found

As a workaround I'm simply running my script with a sudo - definitly not the most secure way to go; but simple enough as a workaround.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.