How to debug database server freeze (not accepting connections, timeouts etc)
So this question is how would you go about finding the problem here? What commands or steps would you run to get more info? 


Monitoring Tool

Do you have a monitoring tool?  If so, check and see what the wait stats are / were during (or at least leading up to) the incident.

Logging Queries and Waits

If you don't have a monitoring tool, I would recommend setting up SQL Server Agent jobs to log information about wait stats and active queries to a table for later analysis.  There are a number of ways to do this, such as:


How to Log Activity Using sp_whoisactive (for active queries)
How to Log Wait Stats to Table with sp_BlitzFirst (for wait stats)
Wait statistics, or please tell me where it hurts (great overview of your top waits)


DAC

While the problem is occurring, you could connect to SQL Server using the dedicated admin connection, and then run sp_WhoIsActive to see exactly what is running and slowing things down.  Despite not accepting connections from other sources, you should still be able to connect this way.




  When I say it hangs, I mean that nothing goes through on any database. The whole DB server just stops working. The OS and server is fine though. Its just the SQL Server instance.


Blocking

This sounds very much like you're experiencing a long blocking chain that never gets resolved - possibly due to long-running queries, but it could also be due to issues with replica synchronization.  Keep an eye out for LCK_* waits (for the blocking chains).  

Slow Synchronous Commits

You mentioned "always on" and if by this you mean Availability Groups, then look out for HADR_SYNC_COMMIT (for the replica synchronization issues).  If the secondary gets overloaded or overly busy, throughput could stall on the primary while waiting for acknowledgements from the secondary.

Poison Waits

It's also possible you're experiencing "poison waits."  Look carefully for those waits in the wait info you start logging (specifically RESOURCE_SEMAPHORE* and THREADPOOL).  This seems less likely to me though, as it probably shouldn't be going on for long periods of time.




  Btw, I am not a DBA but I dont quite get why SQL Server doesnt automatically failover since nothing works on master


This means the server is still responding to "are you up?" checks from the cluster manager, likely because the problem is blocking-related, which is "expected behavior" from SQL Server.  Things are running, they're just not running well.

Additionally, depending on your setup, you might never get automatic failover (if, for example, you have an availability group configured with only an async replica as the secondary).