I have created a shell script on a ubuntu server X with geth Node installed,to insert data in a smart contract in testnet blockchain. Further I am executing the shell script from a PHP file insertscript.php created on the same server X by using shell_exec command. When I call the PHP script from the command prompt , it gets successfully executed and data gets inserted in the blockchain . But when I call the php script from another server by using cURL or open it in the browser, I will see the error :

Fatal: Unable to attach to remote geth: dial unix ///home/ubuntu/.ethereum/testnet/geth.ipc: connect: permission denied

My shell script looks something like:-


echo $STATUS


var abi = [abi definition];
var address = "addressofContract";
var mycontract = web3.eth.contract(abi).at(address);
eth.defaultAddress = eth.accounts[0];



Could you help in finding the cause of this error and also in finding a solution to the same?

1 Answer 1


This happens because your geth binary runs under one user_id, but the webserver runs under another user_id (probably nobody,www ,or etc)

You have to make the geth.ipc file readable and writable to your webserver, either by group access or by using the same user_id on both processes (the webserver and geth)

Also, note that you can not share geth access via IPC (Inter Process Communication) between 2 computers, the IPC works only inside a single computer because it is a kernel-level implementation of data sharing.

  • Hi Nulik...thanks for your response....In my code I changed geth attach $ATTACHPARAMETER << EOF to sudo geth attach $ATTACHPARAMETER << EOF and the Fatal error cannot be seen but the data is still not being inserted. Do you suggest to use rpc instead of ipc?
    – Webdev
    Dec 12, 2017 at 7:11
  • I changed to rpc from ipc and the code worked...thanks
    – Webdev
    Dec 12, 2017 at 13:10
  • I have the same error, but even when my .ipc file has 777 permissions I am seeing the "permission denied" issue Jan 17, 2019 at 14:43
  • @BarneyChambers this in fact occurs if you use virtualization like snap and a file inaccessible to snap app (snap has unofficial very old geth as of current date); theoretically apparmor can also cause that... Feb 27, 2021 at 6:51
  • @BarneyChambers For example: # cat /var/log/kern.log | grep ethereum | tail -1 Feb 27 14:30:12 pc1 kernel: [173119.964487] audit: type=1400 audit(1614407412.004:204): apparmor="DENIED" operation="mknod" profile="snap.geth.geth" name="/media/user/hdd5/home_user_dot_ethereum/geth/LOCK" pid=87400 comm="geth" requested_mask="c" denied_mask="c" fsuid=1000 ouid=1000 Feb 27, 2021 at 6:57

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.