I just created a test doc (article class) in LyX 2.0, insert a URL (in a URL inset) containing a hash character (#), and it worked just fine in PDF output. Escaping it with a backslash caused problems.
That said, if you replace the hash character with %23 in the URL, you get the same result, and that may avoid whatever caused the error message. Paul