Datadir file permissions issue gives confusing error on Windows #11668

issue ekerstein opened this issue on November 12, 2017
  1. ekerstein commented at 9:45 AM on November 12, 2017: none

    I installed the latest version of Bitcoin on a new computer, everything started up normally and it started synchronizing. I closed the program (waited for it to finish) and reopened. When I did that it now says "Cannot obtain a lock on data directory C:\Program Files\Bitcoin. Bitcoin Core is probably already running. Access is denied".

    I've googled the issue, tried deleting the LOCK file, tried uninstalling/reinstalling, and can't get it to work.

    There is one thing I changed during the initial installation. When it asked me where I wanted the blockchain data, I changed it to the Program Files\Bitcoin directory instead of the default user App Data directory. I'm not sure if this is bad or messed something up.

    After I uninstalled and reinstalled, it no longer asks me where I want the blockchain data so I don't know how to change that.

  2. fanquake added the label Windows on Nov 12, 2017
  3. meshcollider commented at 10:28 AM on November 12, 2017: contributor

    Try looking for bitcoin in your task manager or simply restarting windows, to confirm its not still running

  4. DarthJahus commented at 1:39 PM on November 12, 2017: none

    %ProgramFiles% directory usually needs admin permission if a program wants to write there (installed programs have this right, but I don't know how they get it, Bitcoin Qt probably doesn't handle that). You can run Bitcoin Qt client as admin or simply try to choose another folder for data.

    If you don't want %AppData%, it's understandable, but believe me, %ProgramFiles% isn't a good choice and you'll probably forget to back it up before you reinstall Windows, hence lose your wallet and your coins. If you have enough room in your %UserProfile% folder, you can create a folder there for Bitcoin wallet (%UserProfile% is usually in C:\Users\YourNameHere\).

  5. ekerstein commented at 12:31 AM on November 13, 2017: none

    @MeshCollider I restarted and it still didn't work. I also don't see anything in task manager. @DarthJahus I think you're right, my gut feeling is that it has something to do with the directory that I changed it to. How do I reinstall Bitcoin and change the blockchain directory? I've tried uninstalling/reinstalling but it no longer asks me.

  6. meshcollider commented at 12:40 AM on November 13, 2017: contributor

    @ekerstein you can choose a different data directory if you start bitcoin with the -datadir=<datadir> parameter

  7. ekerstein commented at 12:52 AM on November 13, 2017: none

    @MeshCollider Ok I got it to work again by creating a new shortcut with the datadir parameter.

    Does this need to be reported as a bug?

    • I tried using datadir in the bitcoin.conf file but it didn't work. It seems related to #3905 but I wasn't 100% sure if that's still a feature.
    • Maybe using Program Files\Bitcoin should be discouraged
    • Is there an easier way to change the data directory? It seemed to store some stuff in registry, hence the reason it wasn't asking me for the directory again even after uninstall. Maybe that could be made easier?
  8. meshcollider commented at 12:56 AM on November 13, 2017: contributor

    @ekerstein you can start bitcoin once with the -choosedatadir parameter and it will ask you again where to put it, so you don't need to permanently have the -datadir option in the shortcut.

  9. ekerstein commented at 4:38 AM on November 13, 2017: none

    @MeshCollider That worked perfectly, thanks! Everything is running smoothly now. It seems to have been the data directory I chose before.

  10. DarthJahus commented at 11:37 AM on November 13, 2017: none

    Does this need to be reported as a bug?

    Definitely, yes.

    When a software is installed to the Program Files / Program Files (x86) folder, the setup program is always run with administrator rights. This means that the installation program is allowed to change permission settings for a folder.

    Bitcoin installer has to ask for admin rights when launched, or at least when %ProgramFiles% is selected as destination folder for the installation. And if it is installed to Program Files, then it has to change folder permission to allow writing files there.

    Setup tools may allow adding a script line to handle that. Found this blog article that may be interesting.

  11. laanwj renamed this:
    Error: Cannot obtain a lock on data directory
    Datadir file permissions issue gives confusing error on Windows
    on Nov 13, 2017
  12. mikedennis commented at 10:40 PM on November 14, 2017: none

    Maybe using Program Files\Bitcoin should be discouraged

    I agree with this. Putting bitcoin data directory in program files is a bad idea. As mentioned Program Files isn't for program data it's for applications and requires elevated privileges to write to. Typically applications write their data to either %APPDATA% (which I believe is Bitcoin's default) or %PROGRAMDATA% depending on whether it's user specific or not.

  13. laanwj referenced this in commit c290508a5e on Mar 22, 2018
  14. MarcoFalke closed this on Mar 23, 2018

  15. PastaPastaPasta referenced this in commit a6ae63e57b on Sep 27, 2020
  16. PastaPastaPasta referenced this in commit ef0a58ba37 on Oct 22, 2020
  17. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 21:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me