The fact that you are getting an HTTP 401 error from connecting to port 8332 means that something (probably bitcoind) is listening on that port and can understand http. Thus bitcoind the issue is likely not related to bitcoind not connecting to the port but rather that you have configured it incorrectly.
You will get a HTTP 401 Unauthorized error if you do not have the "authorization" header or if the username/password in your auth header is incorrect. For the latter case, if you look in the debug.log file for Bitcoin Core, you will see a line like this:
ThreadRPCServer incorrect password attempt from 127.0.0.1
for each attempt at connecting.
Make sure that you are actually sending the username and password correctly and that what you set as username and password is the same thing as you have set in your bitcoin.conf file.