Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not connect to lockdownd, error code -21 #587

Open
23erter opened this issue Nov 16, 2017 · 9 comments
Open

Could not connect to lockdownd, error code -21 #587

23erter opened this issue Nov 16, 2017 · 9 comments

Comments

@23erter
Copy link

23erter commented Nov 16, 2017

I've done everything step by step but when I write in CMD "ideviceinfo" it tells me: "Could not connect to lockdownd, error code -21"

What should i do to solve it???

@gu-wei
Copy link

gu-wei commented Nov 17, 2017

I have the same issue

@raulsiles
Copy link

raulsiles commented Nov 21, 2017

EDIT 2021-08-01 (by maintainer):
IMPORTANT: Please DO NOT change the permissions of /var/db/lockdown or edit/remove files in it. That is the wrong approach. Use the idevicepair tool to manage device pairings.
Also, please do not run the commands with sudo/as root. That is not required.
Moreover, on macOS there is no need to install the open source usbmuxd since it already has its own. Installing the open source one will most likely break things.
(For clarification: In very early versions of libimobiledevice it was directly accessing these files, before the pair record handling was implemented correctly in usbmuxd).

Original comment:
The "ERROR: Could not connect to lockdownd, error code -21" (for example, simply running "ideviceinfo") is due to a permissions problem in macOS. By default the "/var/db/lockdown" directory has "700" permissions and it is owned by "_usbmuxd:_usbmuxd", like in:
'''
$ sudo ls -ld /var/db/lockdown
drwx------ 2 _usbmuxd _usbmuxd 544 Nov 1 14:45 /var/db/lockdown
'''

Changing the permissions for everyone solves the "-21" error:
'''
$ sudo chmod 705 /var/db/lockdown
$ sudo ls -ld /var/db/lockdown
drwx---r-x 2 _usbmuxd _usbmuxd 544 Nov 1 14:58 /var/db/lockdown
'''

My question is: What should be the right (or minimum) set of permissions for "/var/db/lockdown" in macOS in order to be able to run all the "idevice*" related commands?

@raulsiles
Copy link

raulsiles commented Nov 21, 2017

EDIT 2021-08-01 (by maintainer):
IMPORTANT: Please DO NOT change the permissions of /var/db/lockdown or edit/remove files in it. That is the wrong approach. Use the idevicepair tool to manage device pairings.
Also, please do not run the commands with sudo/as root. That is not required.
Moreover, on macOS there is no need to install the open source usbmuxd since it already has its own. Installing the open source one will most likely break things.
(For clarification: In very early versions of libimobiledevice it was directly accessing these files, before the pair record handling was implemented correctly in usbmuxd).

Original comment:
This issue, when "libimobiledevice" has been installed from brew (latest version, v1.2.0) is also mentioned in issue #188 and #356 (and potentially #588).
As it is due to a permissions issue, it can also be solved using "sudo ideviceinfo" (or other "idevice*" related commands), apart from changing the directory permissions.

@CC-q
Copy link

CC-q commented Dec 18, 2018

EDIT 2021-08-01 (by maintainer):
On macOS there is no need to install the open source usbmuxd since it already has its own. Installing the open source one will most likely break things. So please do not install it.

Original comment:
I have the same issue, and I solved it. It seems that the reason is the version of usbmuxd is too old. And I solved it as follows, hope it helps.
brew update
brew uninstall --ignore-dependencies libimobiledevice
brew uninstall --ignore-dependencies usbmuxd
brew install --HEAD usbmuxd
brew unlink usbmuxd & brew link usbmuxd
brew install --HEAD libimobiledevice
brew link --overwrite libimobiledevice
brew install ideviceinstaller
brew link --overwrite ideviceinstaller

@raulsiles
Copy link

raulsiles commented Dec 19, 2018

A similar procedure, also valid to fix error code -3, is available at the end of issue #717 .

@kwongtailau
Copy link

I delete the old xcode and install the lastest one. It works for me.

@matthewhembree
Copy link

If you stumble upon this in 2021, reference this comment. I am trying to use MVT.

TL;DR: idevicepair unpair then idevicepair pair. No need to change the permissions on /var/db/lockdown.

@nikias
Copy link
Member

nikias commented Aug 1, 2021

Thanks @matthewhembree for pointing this out. I edited the above comments with some clarifications.

@gelosecurity
Copy link

If you stumble upon this in 2021, reference this comment. I am trying to use MVT.

TL;DR: idevicepair unpair then idevicepair pair. No need to change the permissions on /var/db/lockdown.

This worked for me :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants