How to connect to a server that does not allow an access to the root path?

With HTTP-based servers (WebDAV or S3), it is possible that the server does not allow an access to the URL root path, like

With WebDAV, the server often runs on a subfolder, like Accessing a folder outside of the WebDAV root will often result in a error message “405 Method Not Allowed”.

With S3, your credentials may disallow an access to a bucket list, which WinSCP otherwise presents as a root.

In these cases, you have to configure WinSCP to start in the subfolder straight away.


In GUI, you do that by filling the path (e.g. /dav or /bucketname) to Local directory box on Directories page of Advanced Site Settings dialog. Particularly with WebDAV, a handy shortcut is to paste a full URL ( on Login dialog. WinSCP will parse the path out of the URL automatically.


In scripting, specify the path directly in session URL in open command:

open davs://

.NET assembly

In .NET assembly, use SessionOptions.RootPath:

C# example:

SessionOptions sessionOptions = new SessionOptions
    Protocol = Protocol.Webdav,
    HostName = "",
    RootPath = "/dav",

Generated Script/Code

Note that even if you have the script or code generated from a working WinSCP GUI session, it won’t include the root path, as the GUI cannot be aware of the root path restriction.

Last modified: by