I copied your code into hello.c , and debugged it on TWR-K60D100M, found that the socket was created successfully. How many tasks running in your system? Please check your MQX stack usage. Maybe you need to increase the stack size if there is no enough memory.