web server to read file from SD card and show its content as HTML

If you can't open the file with SD.open(filename), then there are normally two reasons.

  1. Opening a SD file takes a lot of SRAM, and you ran out.
  2. The file doesn't exist

I get an error but when I try to open it on startup its working OK.

Post the code that did work when you opened the file in setup().