The URL (appium server endpoint) used in the code is incorrect.
Try using "http://127.0.0.1:4723/" instead of "http://127.0.0.1:4723/wd/hub".