diff --git a/rpc/comms/ipc_unix.go b/rpc/comms/ipc_unix.go index 9d90da0719..d68363a454 100644 --- a/rpc/comms/ipc_unix.go +++ b/rpc/comms/ipc_unix.go @@ -21,6 +21,7 @@ package comms import ( "net" "os" + "path/filepath" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" @@ -69,7 +70,11 @@ func (self *ipcClient) reconnect() error { } func startIpc(cfg IpcConfig, codec codec.Codec, initializer func(conn net.Conn) (shared.EthereumApi, error)) error { - os.Remove(cfg.Endpoint) // in case it still exists from a previous run + // Ensure the IPC path exists and remove any previous leftover + if err := os.MkdirAll(filepath.Dir(cfg.Endpoint), 0751); err != nil { + return err + } + os.Remove(cfg.Endpoint) l, err := net.ListenUnix("unix", &net.UnixAddr{Name: cfg.Endpoint, Net: "unix"}) if err != nil {