If you are using the Open Broadcaster Software you might get the following error code: Failed to connect to server.
This could be caused by different things. First, please check if you are using the right settings. You can do so here:
Your Stream Key?
Everything alright? Then please check your stream key. Did you paste a space into it to cause this error? Best thing would be to generate a new stream key just to be sure. You can do so here:
Bind to IP
If this doesn't help there is only one way left to solve this problem. Please open OBS and go to Settings>Advanced and at the bottom, there is an option called "Bind to IP". Just try all options including Default and click "Start streaming" for all of them. One of these options should enable you to stream without any more errors.