A netrc file is used to hold credentials necessary to login to your labkey server and authorize access to data stored there. The netrc file contains configuration and autologin information for the File Transfer Protocol client (FTP) and other programs. It may be used when working with SAS Macros
, Transformation Scripts in Java
or using the Rlabkey package
If you receive "unauthorized" error messages when trying to retrieve data from a remote server you should check that your netrc file is configured correctly, you have an entry for that remote machine, and the login credentials are correct. Additional troubleshooting
assistance is provided below.
Set Up a netrc File
On a Mac, UNIX, or Linux system the netrc file should be named .netrc (dot netrc) and on Windows it should be named
_netrc (underscore netrc). The file should be located in your home directory and the permissions
on the file must be set so that you are the only user who can read it, i.e. it is unreadable to everyone else. It should be set to at least Read (400), or Read/Write (600)
To create the netrc on a Windows machine, first create an environment variable called ’HOME’
that is set to your home directory (c:/Users/<User-Name> on Vista or Windows 7) or any directory you want to
In that directory, create a text file with the prefix appropriate to your system, either an underscore or dot.
The following three lines must be included in the file. The lines must be separated by either white space
(spaces, tabs, or newlines) or commas:
One example would be:
Another example would be:
machine mymachine.labkey.org login email@example.com password mypassword
Note that the netrc file only deals with connections at the machine level and should not include a port or protocol designation, meaning both "mymachine.labkey.org:8888" and "https://mymachine.labkey.org" are incorrect.
If you see an error message similar to "Failed connect to mymachine.labkey.org:443; Connection refused", remove the port number from your netrc machine definition.
An error message similar to "HTTP request was unsuccessful. Status code = 401, Error message = Moved Temporarily" could indicate an incorrect location for your netrc file. In a typical installation, R will look for libraries in a location like \home\R\win-library. If instead your installation locates libraries in \home\Documents\R\win-library, for example, then the netrc file would need to be placed in \home\Documents instead of the \home directory.