Socket.gethostbyname is usually fast if your local machine has a normal name, because it crashes early, but if you have a name that looks like a real domain things take 5s.
Internally webbrick/config.rb does:
ruby -r socket -e 'Socket.gethostbyname(Socket.gethostname)'
Which is slow … wait for https://bugs.ruby-lang.org/issues/13007 to resolve … or rename your localhost to something that does not look like a domain to ruby.