in TWS, you have to enable API. in TWS, go to EDIT / GLOBAL CONFIGURATION menu
On the screen that comes up, click on API on the left side (about half way down), then click on SETTINGS on the right side.
On the API SETTINGS screen, check the box for "Enable ActiveX and Socket Clients" at the top. Leave everything else as default. On the bottom, there is a section for Trusted IP Addresses. Add 127.0.0.1
Once you do that and apply or hit OK, you should be able to connect with MT